#include "stdafx.h" #include#include #include #include #include #include int main( int argc, char** argv ) { int height ,width ,step ,channels ; int i,j,k,same ,max,min,thresh,sum; uchar*data0,*data1 ; //char *filename="result.bmp"; // IplImage* Img,*nimg; //声明IplImage指针 //载入图像 IplImage* nimg = cvLoadImage("1.jpg"); IplImage* Img = cvCreateImage(cvGetSize(nimg),8,1); cvCvtColor( nimg, Img, CV_BGR2GRAY ); height = Img->height; width = Img->width; step = Img->widthStep/sizeof(uchar); channels = Img->nChannels; data0 = (uchar*)Img->imageData; data1 = (uchar*)nimg->imageData; printf("Processing a %d X %d image with %d channels\n",width,height,channels); int OffSetX[37] = { -1, 0, 1, -2,-1, 0, 1, 2, -3,-2,-1, 0, 1, 2, 3, -3,-2,-1, 0, 1, 2, 3, -3,-2,-1, 0, 1, 2, 3, -2,-1, 0, 1, 2, -1, 0, 1 }; int OffSetY[37] = { -3,-3,-3, -2,-2,-2,-2,-2, -1,-1,-1,-1,-1,-1,-1, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3 }; max = min = data0[0]; //for(i=0;i max) max = data0[i*step+j]; //if(data0[i*step+j]