fft syntax

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
geoland
Posts: 74
Joined: 2015-05-14T05:11:38-07:00
Authentication code: 6789

fft syntax

Post by geoland »

I'm attempting to reproduce the notch filtering demo on the fft page and playing with mask creation ATM - the twig image example.

How should I write the last line as a one-liner?

Code: Select all

convert LOGO.png -fft +delete -colorspace gray -auto-level -evaluate log 100000 logo_spectrum.png

convert logo_spectrum_mask.png logo_spectrum.png -compose difference -composite -threshold 0 -negate logo_spectrum_mask1.png

convert LOGO.png -fft \
          \( -clone 0 logo_spectrum_mask1.png -compose multiply -composite \) \
          -swap 0 +delete  -ift logo_filtered.png
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: fft syntax

Post by fmw42 »

I do not understand what you want to do. You talk about the twig image, but your code says LOGO.png? This is confusing. Also you say you want to write the last line (presumably of your code example) as a one-liner, but it is already one line. Please clarify your question in more detail. I do not see where you create the mask image and I do not see where you have saved the phase image.
geoland
Posts: 74
Joined: 2015-05-14T05:11:38-07:00
Authentication code: 6789

Re: fft syntax

Post by geoland »

Thanks fwm42.

I am following the procedure from the fft notch filtering example. In my previous post twigs was replaced with logo - my test image.

All I want to do is remove \ from the syntax and put each expression on a single line and avoid newlines - this was simple enough with the first two convert commands, but produced errors with the third.

Eventually, this process will be included in a bash script. The manual masking will be performed using IMs display. Once the masking is complete the script will continue. Early days yet, but I would like to avoid newlines if I can. I think the third expression is correct but when running in a terminal complains about the first (

"Lets try this on an another example. This time on a "Twigs" image found on the RoboRealm website, which contains an irregular pattern of horizontal and vertical stripes."

"Again we extract a grey-scale spectrum image, just as we did before."

Code: Select all

convert twigs_spectrum_edited.png twigs_spectrum.png  -compose difference -composite  -threshold 0 -negate twigs_spectrum_mask.png
"Again we mask out the parts using a image editor, this time using a 'blue' color (it really doesn't matter which color is used)..." the manual masking

Code: Select all

convert twigs_spectrum_edited.png twigs_spectrum.png -compose difference -composite -threshold 0 -negate twigs_spectrum_mask.png
"Now we again multiply the mask with the FFT magnitude image, and reconstruct the image"

Code: Select all

convert twigs.jpg -fft \( -clone 0 twigs_spectrum_mask.png -compose multiply -composite \)  -swap 0 +delete  -ift twigs_filtered.png 
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: fft syntax

Post by fmw42 »

You should be able to remove newline slashes without a change in the result.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: fft syntax

Post by fmw42 »

On IM 6.9.4.9 Q16 Mac OSX, I get exactly the same results from:

Code: Select all

convert twigs.jpg -fft \
\( -clone 0 twigs_spectrum_mask.png -compose multiply -composite \) \
-swap 0 +delete  -ift twigs_filtered1.png

Code: Select all

convert twigs.jpg -fft \( -clone 0 twigs_spectrum_mask.png -compose multiply -composite \) -swap 0 +delete  -ift twigs_filtered2.png

Code: Select all

compare -metric rmse twigs_filtered1.png twigs_filtered2.png null:
0 (0)
geoland
Posts: 74
Joined: 2015-05-14T05:11:38-07:00
Authentication code: 6789

Re: fft syntax

Post by geoland »

Thanks. I'll take another look.
Version: ImageMagick 7.0.7 (latest compiled from source) Q32 x86_64 (as of) 2018 - 04 - 31 xubuntu
Post Reply