iOS Laplacian formula detect blur image or not

asked 2014-06-02 06:55:49 -0600

nikunj gravatar image

updated 2014-06-11 07:30:59 -0600

Hello All,

Thanks for help in advance.

In my app, I need when capture image and then check image is blur or not,

So please can you suggest me is it possible with OpenCv for checking image is blur or not?

And I also see that it is working in Android with this link

I have lots of R&D and search but I can't find any solution for detect blur image or not.

I have used this https://github.com/BloodAxe/OpenCV-Tutorial and for blur detection used Laplacian formula but can't get blur detection in image

-(void) checkForBurryImage:(UIImage *) image {

cv::Mat matImage = [image toMat];
cv::Mat matImageGrey;
cv::cvtColor(matImage, matImageGrey, CV_BGRA2GRAY);

cv::Mat dst2 =[image toMat];
cv::Mat laplacianImage;
dst2.convertTo(laplacianImage, CV_8UC1);
cv::Laplacian(matImageGrey, laplacianImage, CV_8U);
cv::Mat laplacianImage8bit;
laplacianImage.convertTo(laplacianImage8bit, CV_8UC1);
//-------------------------------------------------------------
//-------------------------------------------------------------
unsigned char *pixels = laplacianImage8bit.data;
//-------------------------------------------------------------
//-------------------------------------------------------------
 //    unsigned char *pixels = laplacianImage8bit.data;
int maxLap = -16777216;

for (int i = 0; i < ( laplacianImage8bit.elemSize()*laplacianImage8bit.total()); i++) {
    if (pixels[i] > maxLap)
        maxLap = pixels[i];
}

int soglia = -6118750;

printf("\n maxLap : %i",maxLap);


if (maxLap < soglia || maxLap == soglia) {
    printf("\n\n***** blur image *****");
}else
    printf("\nNOT a blur image"); }

And I used same code as Android and its working but not in iPhone,

Please give me any idea or link or code so I can integrate it in my app.

edit retag flag offensive close merge delete