Page 1 of 1

Noise Reduction

Posted: 2009-02-07T23:15:52-07:00
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

Re: Noise Reduction

Posted: 2009-02-08T16:08:56-07:00
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

Re: Noise Reduction

Posted: 2009-02-09T12:56:45-07:00
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.

Re: Noise Reduction

Posted: 2009-02-09T16:20:39-07:00
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

Re: Noise Reduction

Posted: 2009-02-09T16:36:22-07:00
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

Re: Noise Reduction

Posted: 2009-02-09T17:52:56-07:00
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.

Re: Noise Reduction

Posted: 2009-02-09T19:05:51-07:00
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.

Re: Noise Reduction

Posted: 2009-02-10T15:35:25-07:00
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

Re: Noise Reduction

Posted: 2009-02-10T16:18:14-07:00
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.

Re: Noise Reduction

Posted: 2009-02-10T16:58:33-07:00
by el_supremo
Change all the single quote characters to the double quote character.

Pete

Re: Noise Reduction

Posted: 2009-02-10T17:16:27-07:00
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

Re: Noise Reduction

Posted: 2009-02-10T18:56:31-07:00
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!