Fred's ImageMagick Scripts
|
Deblurs an image in the frequency domain using an ideal deblurring filter for either motion blur or lens defocus. |
last modified: August 22, 2009
|
USAGE: cameradeblur [-t type] [-a amount] [-r rotation] [-n noise] [-m method] infile outfile
-t ... type ........ type of blur; choices are: motion (or m) or PURPOSE: To deblur an image in the frequency domain using an ideal deblurring filter for either motion blur or lens defocus. DESCRIPTION: CAMERADEBLUR deblurs an image in the frequency domain using an ideal frequency domain deblurring filter for either motion blur or lens defocus. The motion blur filter in the frequency domain is just an optionally rotated 1D sinc function. The lens defocus filter in the frequency domain is just a jinc function. The user specifies the parameters needed to create those functions directly as images.An explicit filter image is not input to the script. Then it will be divided into the Fourier transform of the image created with +fft and the results will then be returned to the spatial domain via the inverse Fourier transform using +ift. Any alpha channel on the filter will be removed automatically before processing. If the image has an alpha channel it will not be processed, but simply copied from the input to the output. ARGUMENTS: -t type ... TYPE of blur. The choices are: motion (or m) and defocus (or d). The default=defocus. -a amount ... AMOUNT of blur. This is either the length of the motion blur or the diameter of the lens defocus. Values are float>0. The default=10. -r rotation ... ROTATION angle in degrees specified clockwise from horizontal for the motion blur. Values are floats with -180<=rotation<=180. The default=0. -n noise ... NOISE is the estimate of the small constant added to the denominator in the division process and represents the noise to signal power ratio. Values are floats>=0. Usually, one simply uses trial an error with an arbitrary small value for the noise, typically, in the range of about 0.001 to 0.0001. However, it can be estimated from the variance of a nearly constant section of the image (to get the noise variance) divided by an estimate of the variance of the whole image (to get the signal variance). Values are floats>=0. The default=0 -m method ... METHOD for computing the defocus filter. The choices are: slow (or s) or fast (or f). The slow method will be more precise. The default=fast. REQUIREMENTS: IM version 6.5.4-7 or higher, but compiled with HDRI enabled in any quantum level of Q8, Q16 or Q32. Also requires the FFTW delegate library. See Fourier Transform with ImageMagick, for more details. CAVEAT: No guarantee that this script will work on all platforms, nor that trapping of inconsistent parameters is complete and foolproof. Use At Your Own Risk. |
|
Removing Horizontal Motion Blur |
||
|
Input |
Log Enhanced |
Arguments: |
|
|
|
|
Removing Horizontal Motion Blur With Added Noise |
||
|
Input |
Log Enhanced |
|
|
|
|
|
Arguments: |
Arguments: |
Arguments: |
|
|
|
|
Removing Lens Defocus |
||
|
Input |
Log Enhanced |
Arguments: |
|
|
|
|
Removing Lens Defocus With Added Noise |
||
|
Input |
Log Enhanced |
|
|
|
|
|
Arguments: |
Arguments: |
Arguments: |
|
|
|
|
What the script does is as follows:
This is equivalent to the following IM commands for horizontal motion blur.
|