Noise Reduction

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
mikeytown2

Noise Reduction

Post by mikeytown2 »

In terms of command line switches there are 7 noise reduction calls?
-noise (radius)
-median (radius)
-convolve (kernel)
-despeckle
-adaptive-blur (radius[xsigma])
-gaussian-blur (radiusxsigma)
-blur (radiusxsigma)

Is there anything else, and is there an example page for the above 7 commands?
Thanks!

EDIT - Feb 8, 2009: Added -blur & -gaussian-blur to list
Last edited by mikeytown2 on 2009-02-08T16:34:05-07:00, edited 2 times in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Noise Reduction

Post by fmw42 »

mikeytown2 wrote:In terms of command line switches there are 5 noise reduction calls?
-noise (radius)
-median (radius)
-convolve (kernel)
-despeckle
-adaptive-blur (radius[xsigma])

Is there anything else, and is there an example page for the above 5 commands?
Thanks!
-blur
-gaussian-blur

see
http://www.imagemagick.org/Usage/convolve/

see also my noise reduction scripts: isonoise, morphology and statsfilt at http://www.fmwconcepts.com/imagemagick/index.php
mikeytown2

Re: Noise Reduction

Post by mikeytown2 »

@fmw42
This is the "Guts" of your isonoise correct?

Code: Select all

# process data
# create median filtered version
# get absolute difference image between input and median
# threshold the difference image to locate the noise areas
# multiply median by threshold, original by complement of threshold, and then add results together
#
if convert -quiet -regard-warnings "$infile" +repage "$tmpA"
	then
	convert $tmpA -median $radius $tmp0
	convert $tmpA $tmp0 -compose Difference -composite -threshold $thresh% $tmp1
	convert $tmpA $tmp0 $tmp1 -compose src -composite $outfile
What does +repage do exactly, and why do you need to pay attention to warnings?

So, if I want "smart" noise reduction I can't do it with one command, I need temp files.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Noise Reduction

Post by fmw42 »

mikeytown2 wrote:@fmw42
This is the "Guts" of your isonoise correct?

Code: Select all

# process data
# create median filtered version
# get absolute difference image between input and median
# threshold the difference image to locate the noise areas
# multiply median by threshold, original by complement of threshold, and then add results together
#
if convert -quiet -regard-warnings "$infile" +repage "$tmpA"
	then
	convert $tmpA -median $radius $tmp0
	convert $tmpA $tmp0 -compose Difference -composite -threshold $thresh% $tmp1
	convert $tmpA $tmp0 $tmp1 -compose src -composite $outfile
What does +repage do exactly, and why do you need to pay attention to warnings?

So, if I want "smart" noise reduction I can't do it with one command, I need temp files.
isonoise generally works best if the noise is rather sparse (well-separated), as does the median filter.

+repage is used to remove any possible virtual canvas that might be associated with the input image.

Yes, you can do it all in one command line with parentheses and clone processing.
See http://www.imagemagick.org/Usage/basics/#image_seq
mikeytown2

Re: Noise Reduction

Post by mikeytown2 »

fmw42 wrote:Yes, you can do it all in one command line with parentheses and clone processing.
See http://www.imagemagick.org/Usage/basics/#image_seq
So as an example how would you do this with one command?
http://www.imagemagick.org/Usage/advanced/#gel_effects

It's taking output from the last run as input for the next level. A 4 step process
Generate Shape
Add Highlight to input
Darken Borders of input
Add text on top of input

Is there a way to get that down to one line, no temp files? Oversimplified Example:
convert GenShape().Highlight().Borders().Text() out.png
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Noise Reduction

Post by fmw42 »

mikeytown2 wrote:
fmw42 wrote:Yes, you can do it all in one command line with parentheses and clone processing.
See http://www.imagemagick.org/Usage/basics/#image_seq
So as an example how would you do this with one command?
http://www.imagemagick.org/Usage/advanced/#gel_effects

It's taking output from the last run as input for the next level. A 4 step process
Generate Shape
Add Highlight to input
Darken Borders of input
Add text on top of input

Is there a way to get that down to one line, no temp files? Oversimplified Example:
convert GenShape().Highlight().Borders().Text() out.png
Anthony shows in his gel example how to do it in one step (for command line). I don't know anything about using APIs.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Noise Reduction

Post by anthony »

Gel Effect example
http://www.imagemagick.org/Usage/advanced/#gel_effects


Experiment, if you come up with a better or different technique, please me me know.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Noise Reduction

Post by fmw42 »

mikeytown2 wrote:
fmw42 wrote:Yes, you can do it all in one command line with parentheses and clone processing.
See http://www.imagemagick.org/Usage/basics/#image_seq
So as an example how would you do this with one command?
http://www.imagemagick.org/Usage/advanced/#gel_effects

It's taking output from the last run as input for the next level. A 4 step process
Generate Shape
Add Highlight to input
Darken Borders of input
Add text on top of input

Is there a way to get that down to one line, no temp files? Oversimplified Example:
convert GenShape().Highlight().Borders().Text() out.png
This works to make the gel example in one long command line, but I am not sure how to get rid of the miff:- | convert -


convert \( -size 100x60 xc:none \
-fill red -draw 'circle 25,30 10,30' \
-draw 'circle 75,30 90,30' \
-draw 'rectangle 25,15 75,45' \) \
\( +clone -fx A +matte -blur 0x12 -shade 110x0 -normalize \
-sigmoidal-contrast 16,60% -evaluate multiply .5 \
-roll +5+10 +clone -compose Screen -composite \) \
-compose In -composite \
\( +clone -alpha extract -blur 0x2 -shade 0x90 -normalize \
-blur 0x2 +level 60,100% -alpha On \) \
-compose Multiply -composite miff:- |\
convert - -font Candice -pointsize 24 -fill white -stroke black \
-gravity Center -annotate 0 "Gel" -trim -repage 0x0+4+4 \
\( +clone -background navy -shadow 80x4+4+4 \) +swap \
-background none -flatten gel_button.png
mikeytown2

Re: Noise Reduction

Post by mikeytown2 »

Thanks for taking the time to do that! Getting rid of the Escaped CR/LF and putting this into the command line on windows... it crashes ImageMagick.

Code: Select all

convert \( -size 100x60 xc:none -fill red -draw 'circle 25,30 10,30' -draw 'circle 75,30 90,30' -draw 'rectangle 25,15 75,45' \) \( +clone -fx A +matte -blur 0x12 -shade 110x0 -normalize -sigmoidal-contrast 16,60% -evaluate multiply .5 -roll +5+10 +clone -compose Screen -composite \) -compose In -composite \( +clone -alpha extract -blur 0x2 -shade 0x90 -normalize -blur 0x2 +level 60,100% -alpha On \) -compose Multiply -composite miff:- |convert - -font Candice -pointsize 24 -fill white -stroke black -gravity Center -annotate 0 "Gel" -trim -repage 0x0+4+4 \( +clone -background navy -shadow 80x4+4+4 \) +swap -background none -flatten gel_button.png
Gives

Code: Select all

convert: unable to open image `\(': No such file or directory @ blob.c/OpenBlob/2403.
convert: image sequence is required `+clone' @ convert.c/ConvertImageCommand/848.
Getting rid of the escaped ) & ( makes the code error out as well

Code: Select all

convert ( -size 100x60 xc:none -fill red -draw 'circle 25,30 10,30' -draw 'circle 75,30 90,30' -draw 'rectangle 25,15 75,45' ) ( +clone -fx A +matte -blur 0x12 -shade 110x0 -normalize -sigmoidal-contrast 16,60% -evaluate multiply .5 -roll +5+10 +clone -compose Screen -composite ) -compose In -composite ( +clone -alpha extract -blur 0x2 -shade 0x90 -normalize -blur 0x2 +level 60,100% -alpha On ) -compose Multiply -composite miff:- | convert - -font Candice -pointsize 24 -fill white -stroke black -gravity Center -annotate 0 "Gel" -trim -repage 0x0+4+4 ( +clone -background navy -shadow 80x4+4+4 ) +swap -background none -flatten gel_button.png
Gives

Code: Select all

convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: unable to open image `25,30': No such file or directory @ blob.c/OpenBlob/2403.
convert: unable to open image `10,30'': No such file or directory @ blob.c/OpenBlob/2403.
convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: unable to open image `75,30': No such file or directory @ blob.c/OpenBlob/2403.
convert: unable to open image `90,30'': No such file or directory @ blob.c/OpenBlob/2403.
convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `rectangle' @ draw.c/DrawImage/3115.
convert: unable to open image `25,15': No such file or directory @ blob.c/OpenBlob/2403.
convert: unable to open image `75,45'': No such file or directory @ blob.c/OpenBlob/2403.
convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `rectangle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `rectangle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `rectangle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `rectangle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `rectangle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `rectangle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `rectangle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `rectangle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `rectangle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `circle' @ draw.c/DrawImage/3115.
convert: Non-conforming drawing primitive definition `rectangle' @ draw.c/DrawImage/3115.
convert: unable to read font `Candice' @ annotate.c/RenderType/1067.
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Noise Reduction

Post by el_supremo »

Change all the single quote characters to the double quote character.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Noise Reduction

Post by anthony »

to convert a UNIX script version to a window dos version is relatively easy but you need to follow certain things

For example rather than one long, difficult to edit and understand line, use ^ instead of backslashes at teh end of the line.

For the list of changes that needs to be made see
http://www.imagemagick.org/Usage/api/#windows
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
mikeytown2

Re: Noise Reduction

Post by mikeytown2 »

Sweet, thanks for the help! got it working. Tried to make it "easier" to read, but I can't use indentations.

Code: Select all

convert ( ^
-size 100x60 xc:none ^
-fill red -draw "circle 25,30 10,30" ^
-draw "circle 75,30 90,30" ^
-draw "rectangle 25,15 75,45" ^
) ^
( ^
+clone -fx A +matte -blur 0x12 -shade 110x0 -normalize ^
-sigmoidal-contrast 16,60% -evaluate multiply .5 ^
-roll +5+10 +clone -compose Screen -composite ^
) ^
-compose In -composite ^
( ^
+clone -alpha extract -blur 0x2 -shade 0x90 -normalize ^
-blur 0x2 +level 60,100% -alpha On ^
) ^
-compose Multiply -composite miff:- | ^
convert - -pointsize 24 -fill white -stroke black ^
-gravity Center -annotate 0 "Gel" -trim -repage 0x0+4+4 ^
( ^
+clone -background navy -shadow 80x4+4+4 ^
) ^
+swap ^
-background none -flatten gel_button.png
I'll be playing around with what you guys have shown me. Time to go back to the point of the thread. Noise Reduction!
Post Reply