//#include <opencv2\opencv.hpp>//using namespace CV;#include<opencv2/core/core.hpp>#include<opencv2/imgproc/imgproc.hpp>#include<opencv2/highgui/highgui.hpp>#include<iostream>#include"cv.h"using namespaceCV;using namespacestd;DoubleFocus (iplimage*image);intMain () {Iplimage*Previous1; Iplimage*Previous2; Iplimage*Previous3; Iplimage*PREVIOUS4; Previous1= Cvloadimage ("D:/2222/1 (1). jpg",1); Previous2= Cvloadimage ("D:/2222/1 (2). jpg",1); Previous3= Cvloadimage ("D:/2222/1 (3). jpg",1); PREVIOUS4= Cvloadimage ("D:/2222/1 (4). jpg",1); if(Previous1! =0&& Previous2! =0&& PREVIOUS3! =0&& PREVIOUS4! =0) {Cvnamedwindow ("Previous1",1); Cvshowimage ("Previous1", PREVIOUS1); Cvnamedwindow ("Previous2",1); Cvshowimage ("Previous2", PREVIOUS2); Cvnamedwindow ("Previous3",1); Cvshowimage ("Previous3", PREVIOUS3); Cvnamedwindow ("PREVIOUS4",1); Cvshowimage ("PREVIOUS4", PREVIOUS4); cout<<"The definition of the Previous1 is:"<< Focus (PREVIOUS1) <<Endl; cout<<"The definition of the Previous2 is:"<< Focus (PREVIOUS2) <<Endl; cout<<"The definition of the Previous3 is:"<< Focus (PREVIOUS3) <<Endl; cout<<"The definition of the PREVIOUS4 is:"<< Focus (PREVIOUS4) <<Endl; //turn off the window and end Cvwaitkey (0); Cvdestroywindow ("Previous1"); Cvreleaseimage (&Previous1); Cvdestroywindow ("Previous2"); Cvreleaseimage (&previous2); Cvdestroywindow ("Previous3"); Cvreleaseimage (&PREVIOUS3); Cvdestroywindow ("PREVIOUS4"); Cvreleaseimage (&PREVIOUS4); return 0; } return-1;}DoubleFocus (iplimage*image) {Iplimage*picone = Cvcreateimage (cvgetsize (image),8,3); Cvcvtcolor (image, Picone, CV_BGR2YCRCB); Cvscalar gety; Doublez =0, zy1 =0, Zy2 =0, total =0; DoubleGety1 =0, Gety2 =0; DoubleFinal =0; for(intIX =0; IX < (picone->height); ix++) {gety1=0; Gety2=0; Zy1=0; Zy2=0; for(intJY =0; JY < (picone->width); jy++) {gety=cvget2d (Picone, IX, JY); Z=0.5*gety.val[0]-gety1 +0.5*gety2 + zy1-0.5*Zy2; Total= Total +Z; Gety2=gety1; Gety1= gety.val[0]; Zy2=zy1; Zy1=Z; }} cvreleaseimage (&Picone); Final= ABS (Total/((image->height) * (image->width)); returnfinal;}
Image Blur Judgment Program (C + +, OPENCV)