Fred's ImageMagick Scripts
|
Performs deconvolution on an image in the frequency domain. |
last modified: August 22, 2009
|
USAGE: fftdeconvol [-n noise] infile filtfile outfile
-n .... noise .... estimate of the noise to signal power ratio; float>=0; PURPOSE: To perform deconvolution on an image in the frequency domain. DESCRIPTION: FFTDECONVOL perform deconvolution on an image in the frequency domain using a filter image and an estimate of the noise to signal power ratio. Two inputs are required. The convolved image and a grayscale spatial domain convolution filter. Both the convolved image and the grayscale spatial domain convolution filter are transformed to the frequency domain using +fft. Then the fft of the image is divided by the fft of the filter and the product is then returned to the spatial domain using +ift. Since the filter may have noise, which will get amplified by the division when the signal is near zero, a small constant, representing the noise to signal power ratio is added to the denominator prior to the division in order to avoid a division by zero. 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. Currently useful only for deconvolving an image that has been blurred a the convolution. ARGUMENTS: -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. But there are techniques for making a proper estimate. The default=0. The filter image must be appropriately centered and padded with black to the same size as the input image. 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 |
Filter |
Arguments: |
|
|
|
|
Removing Horizontal Motion Blur With Added Noise |
||
|
Input |
Filter |
|
|
|
|
|
Arguments: |
Arguments: |
Arguments: |
|
|
|
|
Removing Lens Defocus |
||
|
Input |
Filter |
Arguments: |
|
|
|
|
Removing Lens Defocus With Added Noise |
||
|
Input |
Filter |
|
|
|
|
|
Arguments: |
Arguments: |
Arguments: |
|
|
|
|
What the script does is as follows:
This is equivalent to the following IM commands.
|