Ask Your Question

Revision history [back]

In general, sum of magnitude of image shows focus fluctuations (smoothness).in special case, you can check the zero crossing in specific points of image. For more accurate value for smoothness compute FFT for image then you can survey the high pass frequency of image.

In general, sum of magnitude of image shows focus fluctuations (smoothness).in (smoothness).In special case, you can check the zero crossing in specific points of image. For more accurate value for smoothness compute FFT for image then you can survey the high pass frequency of image.

In general, sum of magnitude of image shows focus fluctuations (smoothness).In special case, you can check the zero crossing in specific points of image. For more accurate value for smoothness compute FFT for image then you can survey the high pass frequency of image.image. C: double calcGradients(const IplImagesrc,intaperture_size=7) { CvSize sz=cvGetSize(src); IplImageimg16_x=cvCreateImage(sz,IPL_DEPTH_16S,1); IplImageimg16_y=cvCreateImage(sz,IPL_DEPTH_16S,1); cvSobel(src,img16_x,1,0,aperture_size); cvSobel(src,img16_y,0,1,aperture_size); IplImageimgF_x=cvCreateImage(sz,IPL_DEPTH_32F,1); IplImageimgF_y=cvCreateImage(sz,IPL_DEPTH_32F,1); cvScale(img16_x,imgF_x); cvScale(img16_y,imgF_y); IplImagemagnitude=cvCreateImage(sz,IPL_DEPTH_32F,1); cvCartToPolar(imgF_x,imgF_y,magnitude); double res=cvSum(magnitude).val[0]; cvReleaseImage(&magnitude); cvReleaseImage(&imgF_x); cvReleaseImage(&imgF_y); cvReleaseImage(&img16_x); cvReleaseImage(&img16_y); return res; }

C++: double contrast_measure(const Mat&img) { Mat dx,dy; Sobel(img,dx,1,0,3,CV_32F); Sobel(img,dy,0,1,3,CV_32F); magnitude(dx,dy,dx); return sum(dx)[0]; }

In general, sum of magnitude of image shows focus fluctuations (smoothness).In special case, you can check the zero crossing in specific points of image. For more accurate value for smoothness compute FFT for image then you can survey the high pass frequency of image. image.

C:

double calcGradients(const IplImagesrc,intaperture_size=7)
IplImage*src,intaperture_size=7)
{
CvSize sz=cvGetSize(src);
IplImageimg16_x=cvCreateImage(sz,IPL_DEPTH_16S,1);
IplImageimg16_y=cvCreateImage(sz,IPL_DEPTH_16S,1);
IplImage*img16_x=cvCreateImage(sz,IPL_DEPTH_16S,1);
IplImage*img16_y=cvCreateImage(sz,IPL_DEPTH_16S,1);
cvSobel(src,img16_x,1,0,aperture_size);
cvSobel(src,img16_y,0,1,aperture_size);
IplImageimgF_x=cvCreateImage(sz,IPL_DEPTH_32F,1);
IplImageimgF_y=cvCreateImage(sz,IPL_DEPTH_32F,1);
IplImage*imgF_x=cvCreateImage(sz,IPL_DEPTH_32F,1);
IplImage*imgF_y=cvCreateImage(sz,IPL_DEPTH_32F,1);
cvScale(img16_x,imgF_x);
cvScale(img16_y,imgF_y);
IplImagemagnitude=cvCreateImage(sz,IPL_DEPTH_32F,1);
IplImage*magnitude=cvCreateImage(sz,IPL_DEPTH_32F,1);
cvCartToPolar(imgF_x,imgF_y,magnitude);
double res=cvSum(magnitude).val[0];
cvReleaseImage(&magnitude);
cvReleaseImage(&imgF_x);
cvReleaseImage(&imgF_y);
cvReleaseImage(&img16_x);
cvReleaseImage(&img16_y);
return
res;
}

}

C++:

double contrast_measure(const Mat&img)
{
Mat dx,dy;
Sobel(img,dx,1,0,3,CV_32F);
Sobel(img,dy,0,1,3,CV_32F);
magnitude(dx,dy,dx);
return sum(dx)[0];
}

}

In general, sum of magnitude of image shows focus fluctuations (smoothness).In special case, you can check the zero crossing in specific points of image. For more accurate value for smoothness compute FFT for image then you can survey the high pass frequency of image.

C:

double calcGradients(const IplImage*src,intaperture_size=7)
{
CvSize sz=cvGetSize(src);
IplImage*img16_x=cvCreateImage(sz,IPL_DEPTH_16S,1);
IplImage*img16_y=cvCreateImage(sz,IPL_DEPTH_16S,1);
cvSobel(src,img16_x,1,0,aperture_size);
cvSobel(src,img16_y,0,1,aperture_size);
IplImage*imgF_x=cvCreateImage(sz,IPL_DEPTH_32F,1);
IplImage*imgF_y=cvCreateImage(sz,IPL_DEPTH_32F,1);
cvScale(img16_x,imgF_x);
cvScale(img16_y,imgF_y);
IplImage*magnitude=cvCreateImage(sz,IPL_DEPTH_32F,1);
cvCartToPolar(imgF_x,imgF_y,magnitude);
double res=cvSum(magnitude).val[0];
cvReleaseImage(&magnitude);
cvReleaseImage(&imgF_x);
cvReleaseImage(&imgF_y);
cvReleaseImage(&img16_x);
cvReleaseImage(&img16_y);
return
res;
}

C++:

double contrast_measure(const Mat&img)
contrast_measure( Mat& img )
{
 Mat dx,dy;
Sobel(img,dx,1,0,3,CV_32F);
Sobel(img,dy,0,1,3,CV_32F);
magnitude(dx,dy,dx);
dx, dy;
    Sobel( img, dx, CV_32F, 1, 0, 3 );
    Sobel( img, dy, CV_32F, 0, 1, 3 );
    magnitude( dx, dy, dx );
    return sum(dx)[0];
}

In general, sum of magnitude of image shows focus fluctuations (smoothness).In special case, you can check the zero crossing in specific points of image. For more accurate value for smoothness compute FFT for image then you can survey the high pass frequency of image.

C:

double calcGradients(const IplImage*src,intaperture_size=7)
{
CvSize sz=cvGetSize(src);
IplImage*img16_x=cvCreateImage(sz,IPL_DEPTH_16S,1);
IplImage*img16_y=cvCreateImage(sz,IPL_DEPTH_16S,1);
cvSobel(src,img16_x,1,0,aperture_size);
cvSobel(src,img16_y,0,1,aperture_size);
IplImage*imgF_x=cvCreateImage(sz,IPL_DEPTH_32F,1);
IplImage*imgF_y=cvCreateImage(sz,IPL_DEPTH_32F,1);
cvScale(img16_x,imgF_x);
cvScale(img16_y,imgF_y);
IplImage*magnitude=cvCreateImage(sz,IPL_DEPTH_32F,1);
cvCartToPolar(imgF_x,imgF_y,magnitude);
double res=cvSum(magnitude).val[0];
cvReleaseImage(&magnitude);
cvReleaseImage(&imgF_x);
cvReleaseImage(&imgF_y);
cvReleaseImage(&img16_x);
cvReleaseImage(&img16_y);
return
res;
}

C++:

double contrast_measure( Mat& img const Mat&img )
{
    Mat dx, dy;
    Sobel( img, dx, CV_32F, 1, 0, 3 );
    Sobel( img, dy, CV_32F, 0, 1, 3 );
    magnitude( dx, dy, dx );
    return sum(dx)[0];
}