Ask Your Question
4

Detect blur image

asked 2012-10-17 15:47:22 -0600

tuyau2poil gravatar image

Hello, I would like to check blurring on a lot of medical pictures (more than 10000). (the goal is to remove bad files). is it possible ? if yes, can someone give me a simple way to do that ? I'm not a guru in image analysis, and I spent days to look for that kind of tool. I use visual studio to compile numerous c++ files like thislink text but c++ is not my favorite language (nor english! :-) ) and I can't understand the mixing complexity of all this mathematical technology... thank you ! Alan / France'countrySide

edit retag flag offensive close merge delete

Comments

1
Kirill Kornyakov gravatar imageKirill Kornyakov ( 2012-10-18 12:13:07 -0600 )edit

2 answers

Sort by ยป oldest newest most voted
7

answered 2012-10-18 04:41:54 -0600

Ben gravatar image

That's a difficult task. Cameras can change the focus and thus analyse, if the image gets sharper or not. Having only one picture, how can you decide if your image is blurred or if it is a perfectly sharp photo of a Gerhard Richter painting?

Basically, sharpness can be measured by analysing the edges, for example with a Sobel filter. Having strong edges is a good sign for sharpness. But if you don't have high contrasts in your image, it could also mean that you took a picture of something lacking contours.

The good thing is: you probably know, what's represented on your pictures. If you're expecting certain objects, it is easier to define some threshold which classifies the image as blurred or sharp.

edit flag offensive delete link more
0

answered 2012-10-19 16:36:20 -0600

tuyau2poil gravatar image

Thanks you very much for your answers : I finaly use Laplacian/gauss filter and get stronger pixel to estimate blur : it's Ok for my need. I translate C++ code to VB.Net and use EMGU Opencv library. this is my code :

Module Module1
Private Sub GetBlur(ByVal imgfile As String)
    Dim factor As Single
    Dim imgB As Bitmap = New Bitmap(imgfile)
    imgB = New Bitmap(imgB)
    Dim imgGray As Image(Of Gray, Byte) = img.Convert(Of Gray, Byte)()
    Dim imgTmp As Image(Of Gray, Single) = imgGray.Laplace(1)
    Dim maxLap As Short = -32767
    For Each MyByte As Single In imgTmp.Data
        If MyByte > maxLap Then
            maxLap = MyByte
        End If
    Next
    Debug.Print(imgfile & "   " & maxLap)
    imgGray.Dispose()
    img.Dispose()
    imgTmp.Dispose()
    imgB.Dispose()
End Sub

End Module

Where Maxlap is the "blur score" of the picture.

Alan

edit flag offensive delete link more

Comments

Hi Can you please post your code in Java, I am got the other code thats working fine but not working if the object surface white Table, whitewall or If sunlight directly coming at surface and capture image is always detected as a blur.

Amrit gravatar imageAmrit ( 2019-09-26 02:37:28 -0600 )edit

Here is my code: var blur_score = 0.0 try { val image = Imgcodecs.imread(path, Imgcodecs.CV_LOAD_IMAGE_COLOR) if (!image.empty()) { val destination = Mat() val matGray = Mat() Imgproc.cvtColor(image, matGray, Imgproc.COLOR_BGR2GRAY) Imgproc.Laplacian(matGray, destination, CvType.CV_64F) val median = MatOfDouble() val std = MatOfDouble() Core.meanStdDev(destination, median, std) blur_score = DecimalFormat("0.00").format(Math.pow(std.get(0, 0)[0], 2.0)).toDouble() } } catch (e: Exception) { e.printStackTrace() Log.i(TAG, "blurException:"+e.message }

Amrit gravatar imageAmrit ( 2019-09-26 02:38:20 -0600 )edit

Question Tools

2 followers

Stats

Asked: 2012-10-17 15:47:22 -0600

Seen: 21,392 times

Last updated: Oct 19 '12