prs_image = preprocessing(src_image, size, size); 
上面那个代码主要是进行了一下,图片大小归一化的预处理工作。
分类方法使用的knn近邻分类法

解决方案 »

  1.   

    ConvertScaleConverts one array to another with optional linear transformationvoid cvConvertScale( const CvArr* src, CvArr* dst, double scale=1, double shift=0 );#define cvCvtScale cvConvertScale
    #define cvScale  cvConvertScale
    #define cvConvert( src, dst )  cvConvertScale( (src), (dst), 1, 0 )src
        Source array. 
    dst
        Destination array. 
    scale
        Scale factor. 
    shift
        Value added to the scaled source array elements. The function cvConvertScale has several different purposes and thus has several synonyms. It copies one array to another with optional scaling, which is performed first, and/or optional type conversion, performed after:dst(I)=src(I)*scale + (shift,shift,...)All the channels of multi-channel arrays are processed independently.The type conversion is done with rounding and saturation, that is if a result of scaling + conversion can not be represented exactly by a value of destination array element type, it is set to the nearest representable value on the real axis.In case of scale=1, shift=0 no prescaling is done. This is a specially optimized case and it has the appropriate cvConvert synonym. If source and destination array types have equal types, this is also a special case that can be used to scale and shift a matrix or an image and that fits to cvScale synonym.
      

  2.   

    cvConvertScale(&prs_image, img, 0.0039215, 0);这一句就是做归一化哦
    语法原型
    cvConvertScale(const CvArr * src,CvArr *dst, double scale,double shift);
    用法:dst(i) = src(i)*scale + shift
    你的scale = 0.0039215 = 1/255; 
        shift = 0
    注意像素最大值是255.也就是convert 8 bits image to 32 float image将8位转化为32位浮点数表示。