Motion Blur removal

Discuss digital image processing techniques and algorithms. We encourage its application to ImageMagick but you can discuss any software solutions here.
pdaraja
Posts: 28
Joined: 2016-10-31T04:20:19-07:00
Authentication code: 1151

Re: Motion Blur removal

Post by pdaraja »

thank you so much....
pdaraja
Posts: 28
Joined: 2016-10-31T04:20:19-07:00
Authentication code: 1151

Re: Motion Blur removal

Post by pdaraja »

thank you so much....can i see the results what you get for both images..
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Motion Blur removal

Post by fmw42 »

Image 1.png may have motion blur at 45 degrees (upper left to bottom right), but I get a blur amount of 20 px. It is really hard to tell in that image, since there are other distortions showing that are causing larger peaks. I used ImageJ to measure the angle (45 deg) and blur=0.5*(length of the distance between the two tiny dots on opposite sides of the center)=20.

1.png cepstrum
Image


rgb_000354.jpg cepstrum
Image

I used ImageJ to measure the angle and length of the blur between the two tiny dots on opposite sides of the center.
pdaraja
Posts: 28
Joined: 2016-10-31T04:20:19-07:00
Authentication code: 1151

Re: Motion Blur removal

Post by pdaraja »

can i see the unblurred image output for 1.png image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Motion Blur removal

Post by fmw42 »

I have not tried to unblur it, since I was not sure it has only motion blur. I can try tomorrow. It is late for me tonight. There may be other distortions that are more significant than motion blur.

How did you create the motion blurred image?
pdaraja
Posts: 28
Joined: 2016-10-31T04:20:19-07:00
Authentication code: 1151

Re: Motion Blur removal

Post by pdaraja »

http://www194.lunapic.com/editor/?action=motion-blur
this is the link which has the motion blur tool...
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Motion Blur removal

Post by fmw42 »

What was your original input image before blurring? Do you know what algorithm that tool uses?
pdaraja
Posts: 28
Joined: 2016-10-31T04:20:19-07:00
Authentication code: 1151

Re: Motion Blur removal

Post by pdaraja »

https://drive.google.com/file/d/0B6Eilz ... FHWEU/view
this is the original image..
i don't know what is the algorithm is running..but i have given the parameters are motion length in pixels and angle(direction) of motion to blur the image.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Motion Blur removal

Post by fmw42 »

I took a 256x256 section of your rgb_000354.png image to avoid the motion blur from the leg kicking so as not to confuse the cepstrum

Image

I then created a motion blur PSF image of 10 pixels at 45 degrees via:

Code: Select all

convert -size 256x256 xc:black -fill white -draw "translate 128,128 line -4.5,0 +4.5,0" -alpha off -background black -rotate 45 +repage -gravity center -crop 256x256+0+0 +repage psf_motion_10x45.png
Image

I then used my fftconvol script to blur it.

Code: Select all

fftconvol rgb_000354_256.png psf_10x45.png rgb_000354_256_im_fc_10x45.png
Image

I then generated the cepstrum image:

Code: Select all

cepstrum -G rgb_000354_256_im_fc_10x45.png rgb_000354_256_im_fc_10x45_cep.png
Image

Which measures in ImageJ about 9.5-10 pixels at 45 deg (for the half distance between the two inner dots closest to the center)

I then use the same PSF image with an estimated noise of 0.0001 to deblur it.

Code: Select all

fftdeconvol -n 0.0001 rgb_000354_256_im_fc_10x45.png psf_10x45.png rgb_000354_256_im_fc_10x45_fdc_0p0001.png
Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Motion Blur removal

Post by fmw42 »

I do not think Lunapic is using a proper camera type motion blur (simple straight line PSF), but a motion blur effect similar to that in Imagemagick. See http://www.imagemagick.org/Usage/blur/#motion-blur. Note the shape of the blur is like a comet (only one side is blurred).

If I blur your image in Lunapic, I get:

Image

And when I use my same fftdeconvol function to deblur it with the same arguments, I get

Image

The cepstrum looks like this:

Image

which show too many peaks and not clearly motion blur.
pdaraja
Posts: 28
Joined: 2016-10-31T04:20:19-07:00
Authentication code: 1151

Re: Motion Blur removal

Post by pdaraja »

thank you so much for your big support..
again i am getting a big doubt.
For example, i am having a blurry image(motion blur) from the real world as a input, whereas i am not having the original image(clear image of that). now i want to deblur it. what i have to do?
1. because you are having original rgb_000354.png image. then you are adding motion blur with PSF.
2.then your are estimating the noise.
3.then you are retrieving the original image with the PSF information what you have already known.
My question is,
i am having a blurry image(motion blur) with no information about its blurness. how can i estimate the blur kernel(PSF) and how can i deblur it?

so if i want to deblur the image, whether i should add the motion blur to it.
...please help me.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Motion Blur removal

Post by fmw42 »

You can use the cepstrum concept as mentioned above. But if the blur is not "uniform constant linear motion blur", then it won't show a result that will clearly tell you the unique arguments of distance and angle. This failure typically occurs in real images when the motion is not the uniform over the whole image, not the a constant direction or not a constant speed (such a accelerated or jerky motion). So you need to have a very ideal type of motion blur for the ceptstrum to detect it. Otherwise, I have no suggestions.

Your person kicking is not uniform constant linear motion blur, because it occurs only for the leg, not over the whole image and is not constant in direction or speed. To have any hope of deblurring, you would have to crop the part of the image that has the motion.

So an image that might work would be one for which the camera is moving at constant speed (not rotating) which is hard to do with a hand-held camera. Or some thing like a car moving in a straight line at constant speed horizontal to the camera. You could then crop the car and possibly deconvolve it using the cepstrum to measure the arguments.

Defocus is harder, especially when there is change in depth of field. Defocus would only work if viewing a flat object face on. See my example at http://www.fmwconcepts.com/imagemagick/ ... deblurring

Blind deconvolution may reduce some blurs, but it usually only works for psf that when transformed to the frequency domain are non-negative. Motion blur and defocus psf have oscillations in the frequency domain and so blind deconvolution does not work well. Blind deconvolution works more typically for astronomical atmospheric blur which is more gaussian shaped in the frequency domain.

Unfortunately, I have no blind deconvolution functions, but they won't typically work for motion or defocus.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Motion Blur removal

Post by fmw42 »

If you want to provide an real example of an image that had motion blur. I can try to run the cepstrum on it and deblur it. But again, it needs to be a more or less ideal motion blur as defined above.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Motion Blur removal

Post by fmw42 »

One other way to determine motion blur is to find some point object in the scene (such as a corner) and measure its blur distance and angle in the blurred image.
pdaraja
Posts: 28
Joined: 2016-10-31T04:20:19-07:00
Authentication code: 1151

Re: Motion Blur removal

Post by pdaraja »

whether wiener filter, Lucy method and blind deconvolution methods are required a unblurred image to help restore the blurred image?
Post Reply