views:

305

answers:

5

Hi

How can we identify that a given image is blur or how much percent is it blur in C#? Is there any API available for that? Or any algorithm that can be helpful in that?

Thanks!

+1  A: 

Given a blurred bitmap alone, you probably can't.

Given the original bitmap and the blurred bitmap you could compare the two pixel by pixel and use a simple difference to tell you how much it is blurred.

A: 

Err ... do you have the original image? What you ask is not a simple thing to do, though ... if its even possible

This is just a bit of a random though but you might be able to do it by fourier transforming the "blurred" and the original image and seeing if you can get something that has a very similar frequency profiles by progressively low pass filtering the original image in the frequency domain. Testing for "similarity" would be fairly complex in itself though.

Goz
+5  A: 

You could perform a 2D-FFT and search the frequency coefficients for a value over a certain threshold (to elimate false-positives from rounding/edge errors). A blurred image will never have high frequency coefficients (large X/Y values in frequency-space).

If you want to compare with a certain blurring algorithm, run a single pixel through a 2D-FFT and check further images to see if they have frequency components outside the range of the reference FFT. This means you can use the same algorithm regardless of what type of blurring algorithm is used (box blur, gaussian, etc)

matja
+1 - this is the way to go: of course, finding that threshold is non-trivial.
Jacob
+1 this is definitely the way to go. Maybe you want to apply a windowing function to the image first, so you don't have sharp corners at the borders (the FFT "expects" a periodic signal)
nikie
+1. One would need to be careful with the edges though as these will add high frequency power. Also, rather than an absolute threshold, one could look at the total power in LF vs power in HF.
tom10
+1  A: 

Given that I'm guessing you don't have the original image, it might be worthing looking at performing some kind of edge detection on the blurred image.

This Paper suggests a method using Harr Wavelet Transform, but as other posters have said, this is a fairly complex subject.

Jasoon
A: 

Ambigous question.

DBJDBJ