#include #include #include #include #include #pragma warning(disable : 4996) void main () { // const char * Name_Img = "Image.png"; const int Hight = 200; const int Width = 180; IplImage * Image_In; FILE * Fp; double * Interval_1 = malloc (Hight * Width * sizeof(double)); double * Interval_2 = malloc (Hight * Width * sizeof(double)); int i = 0; int j = 0; char c; int N0, N1, N2; N0 = N1 = N2 = 0; c = getchar(); // Image_In = cvLoadImage("Image.png",0); if ((Image_In = cvLoadImage("Photo_In.jpg",0)) == NULL) // Image.png = File of image for comparison { printf ("Error: cvLoadImage can't load the Image\n"); c = getchar(); exit(1); } c = getchar(); // For debug if ((Fp = fopen ("ardper.mass", "rb")) == NULL) // Photo_1.mass = File of array (vector) number 1 { printf ("Error: can't open Photo_1.mass\n"); c = getchar(); exit(1); } for (i = 0; i < Hight; i++) for (j = 0; j < Width; j++) *(Interval_1 + i*Width + j) = sqrt ( abs ( ( ((int) Image_In->imageData[Image_In->widthStep*i + j]) * ((int) Image_In->imageData[Image_In->widthStep*i + j]) ) + ( ((int) fgetc(Fp)) * ((int) fgetc(Fp)) ) ) ); close (Fp); // For debug if ((Fp = fopen ("howar.mass", "rb")) == NULL) { printf ("Error: can't open Photo_2.mass\n"); // Photo_2.mass = File of array (vector) number 2 c = getchar(); exit(1); } for (i = 0; i < Hight; i++) for (j = 0; j < Width; j++) *(Interval_2 + i*Width + j) = sqrt ( abs ( ( ((int) Image_In->imageData[Image_In->widthStep*i + j]) * ((int) Image_In->imageData[Image_In->widthStep*i + j]) ) + ( ((int) fgetc(Fp)) * ((int) fgetc(Fp)) ) ) ); close (Fp); // For debug cvReleaseImage(&Image_In); for (i = 0; i < Hight; i++) for (j = 0; j < Width; j++) { if ( *(Interval_1 + i*Width + j) == *(Interval_2 + i*Width + j) ) N0++; if ( *(Interval_1 + i*Width + j) > *(Interval_2 + i*Width + j) ) N1++; if ( *(Interval_1 + i*Width + j) < *(Interval_2 + i*Width + j) ) N2++; }; if ((N0 > N1) && (N0 > N2)) printf("I don't know\n"); if ((N1 > N0) && (N1 > N2)) printf("ardper\n"); if ((N2 > N0) && (N2 > N1)) printf("howar\n"); c = getchar(); // For debug }