Page 1 of 1

problem with +ift inverse transform of real/imaginary components

Posted: 2017-04-06T17:13:24-07:00
by whilom
This is part of a bigger investigation of why fftdeconvol only returns colourful messes for me. I'm trying to do a simple deblur manually to see where things mess up.

I'm working with 16bit sRGB PNG files and with HRDI configured (and OpenCL if that might be relevant.)

Code: Select all

convert -version
gives:
Version: ImageMagick 6.9.7-9 Q16 x86_64 2017-04-05 http://www.imagemagick.org
Copyright: © 1999-2017 ImageMagick Studio LLC
License: http://www.imagemagick.org/script/license.php
Features: Cipher DPC HDRI Modules OpenCL OpenMP
Delegates (built-in): bzlib cairo fftw freetype jng jpeg ltdl png rsvg x zlib
Source image:

Image

Code: Select all

convert ../crop/_0161908_h4w3.png +fft +ift h4w3_rt.png
gives:

Image

which looks perfectly correct, but

Code: Select all

convert ../crop/_0161908_h4w3.png +fft h4w3_ri.png
convert h4w3_ri-0.png h4w3_ri-1.png +ift h4w3_ri.png
gives:

Image

which has bright corners and washed-out contrast.

I have no problem adjusting contrast in magnitude/phase with -ift. Any ideas what gives?

Thanks kindly!

Re: problem with +ift inverse transform of real/imaginary components

Posted: 2017-04-06T17:32:11-07:00
by fmw42
PNG does not support fractional values or negative values. You must use either MPC, PFM or TIFF with the float -define for your real/imaginary images from the +fft. After the +ift, you are safe to save to PNG.

I always use either MPC or PFM for the output of +fft.

My script, fftconvol and fftdeconvol, need square images to work properly. You do not say what size your images are.

OpenCL will not be used.

If you still have trouble, send me your input image and filter image and your command line(s).

Re: problem with +ift inverse transform of real/imaginary components

Posted: 2017-04-06T17:46:41-07:00
by whilom
:P Yup, and I read that like three times in the fft guide and it still didn't sink in! Thanks bundles!

My images are square powers of two, 512 2k or 4k. Asking for png output from fft{de}convol wouldn't mess the scripts up would it? I'll let you know if my continuing investigation reveals anything other than my own foolishness.

Re: problem with +ift inverse transform of real/imaginary components

Posted: 2017-04-06T17:52:51-07:00
by fmw42
The input and output from fftconvol and fftdeconvol can be png. In the script, I use MPC or PFM for intermediate images from the +fft. So if you are using my script and the images are square and the filter corresponds, then either your noise value is way off or there could be a new bug in the script. I always try several factors of 10 for my noise value to see if I can tune it in, e.g. (0.000001, 0.00001, 0.0001, 0.001, 0.01, 0.1). Then refine by a factor of 5 or 2 once I get close.

Re: problem with +ift inverse transform of real/imaginary components

Posted: 2017-04-06T18:04:35-07:00
by whilom
Yup, that was it, image doesn't start to show through the noise until -n 0.001 or greater. Thanks again!

Re: problem with +ift inverse transform of real/imaginary components

Posted: 2017-04-06T18:32:47-07:00
by fmw42
That is about a typical value that I find also. You might try 0.002 and 0.0005