Page 2 of 2

Re: Request Enhancments Similar to -mode

Posted: 2011-03-29T17:32:39-07:00
by fmw42
Thanks for adding standard-deviation. However, I don't believe it is implemented correctly as it should look like an edge image.

original:
Image

convert lena2g.jpg -statistic standard-deviation 3x3 lena2g_std.jpg

Image


However, from my statsfilt script (which is limited to a 3x3 neighborhood), I get

Image

And after -normalize

convert lena2g_opt6.jpg -normalize lena2g_opt6_norm.jpg

Image

My script uses:

ave="1,1,1,1,1,1,1,1,1"
# -gamma 2 is equivalent to sqrt
# $tmpA is the input image
convert $tmpA -convolve "$ave" $tmp0
convert \( $tmpA $tmpA -compose multiply -composite -convolve "$ave" \) \
\( $tmp0 $tmp0 -compose multiply -composite \) +swap \
-compose minus -composite -gamma 2 $outfile

Re: Request Enhancments Similar to -mode

Posted: 2011-03-29T18:26:57-07:00
by magick
Look for a patch in ImageMagick 6.6.9-2 Beta by sometime tomorrow. Thanks.

Re: Request Enhancments Similar to -mode

Posted: 2011-03-31T20:13:27-07:00
by fmw42
magick wrote:Look for a patch in ImageMagick 6.6.9-2 Beta by sometime tomorrow. Thanks.

Thanks. It is working fine in IM 6.6.9.2 Q16 Mac OSX Tiger

Fred

Re: Request Enhancments Similar to -mode

Posted: 2011-03-31T20:24:11-07:00
by fmw42
P.S. The non-peak option does a nice job of removing noise:

input:
Image

convert lenag_noise_95.jpg -statistic nonpeak 3x3 lenag_noise_95_np3x3.jpg

Image


Can you explain the algorithm concept in simple terms?

Re: Request Enhancments Similar to -mode

Posted: 2011-04-01T07:23:31-07:00
by magick
Replace the pixel with the pixel prior / adjacent to the median.

Re: Request Enhancments Similar to -mode

Posted: 2011-04-01T17:03:06-07:00
by fmw42
magick wrote:Replace the pixel with the pixel prior / adjacent to the median.
I have edited the options page docs to indicate in simple terms what each does. Please correct if I am in error.

Re: Request Enhancments Similar to -mode

Posted: 2011-04-02T18:37:07-07:00
by anthony
magick wrote:Replace the pixel with the pixel prior / adjacent to the median.
I don't understand how this represents a 'non-peak' statistic. That seems to be just another type of 'median'.

Say you have a pixel of value 9, surrounded by other pixels forming a sorted list...
1,3,3,3,5,5,6,9,10
The minimum value is 1, maximum is 10, median (center of sorted list) is 5, most common is 3.
average or mean is add/divide or 5.0 (could be a floating-point value, rounded unless HDRI).

What then is non-peak?

Also would a statistic of (max-min)/2 => 4.5 be useful? (Centric)



Other ''statistics'' from morphology using flat shaped neighbourhood kernels -- EG Squares/Rectangles
Erode => as minimum 1
Dialate => as maximum 10
Convolve => mean 5
Gradient => abs( maximum - minimum ) => 9 (maximum difference in area)
TopHat => abs( pixel - minimum ) => 8 (difference from minimum)
BottomHat => abs( maximim - pixel ) => 1 (difference from maximim)

I am planning on making all 5 operations primitives in IM morphology, At this moment only erode and dialate are primitives, with the other three implemented as composition of primitives (1 or 2 convolutions and 1 compositions of the images)

ASIDE:
Alternative meaning of TopHat (I found BOTH in various papers)
TopHat => pixel - minimum => 8 (difference from minimum)
BottomHat => maximim - pixel => 1 (difference from maximim)

However I can not find a case where the two will be different to the previous definition, though Fred at one point indicated that their was. Fred can you enlighten!

Re: Request Enhancments Similar to -mode

Posted: 2011-04-03T17:41:09-07:00
by anthony
anthony wrote:Other ''statistics'' from morphology using flat shaped neighbourhood kernels -- EG Squares/Rectangles
Erode => as minimum 1
Dialate => as maximum 10
Convolve => mean 5
Gradient => abs( maximum - minimum ) => 9 (maximum difference in area)
TopHat => abs( pixel - minimum ) => 8 (difference from minimum)
BottomHat => abs( maximim - pixel ) => 1 (difference from maximim)
...
Alternative meaning of TopHat (I found BOTH in various papers)
TopHat => pixel - minimum => 8 (difference from minimum)
BottomHat => maximim - pixel => 1 (difference from maximim)
Sorry I mad a mistake with the "Hat" operation defintions above, They are based on Open and Close operations, not dialate and erode (maximum and minimum) and these really does need to be separate operations, so you can't easilly merge them.

Gradient however can be implemented as a primitive statistic.