Request Enhancments Similar to -mode
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Request Enhancments Similar to -mode
I would like to request that -mode widthxheight be replicated to generate other statistical values, in particular -min, -max, -mean and -standard-deviation for a given rectangular widthxheight. I don't know if it is possible to put all the options under one name, such as -stats-filter. If so that would be OK and even better. But perhaps the syntax parser will not currently allow something like -stats-filter widthxheight+type where type is min, max, mean, or standard_deviation. This type of operation could even be expanded to such things as the average of k nearest in value (to the center value) and other such statistical operations.
I realize that -mean can be achieve by -blur radiusx65000 and -min and -max can be achieved via -morphology open/close square:radius, but the latter two are very slow and also I am not really sure how to convert the square:radius to the actual window size. Perhaps it is just radius=half-size. Clarification would be nice from Anthony. None however allow a rectangular area, only square area.
Discussion from others is requested and welcome before any action is taken. Are these worthwhile to others?
Thanks
Fred
I realize that -mean can be achieve by -blur radiusx65000 and -min and -max can be achieved via -morphology open/close square:radius, but the latter two are very slow and also I am not really sure how to convert the square:radius to the actual window size. Perhaps it is just radius=half-size. Clarification would be nice from Anthony. None however allow a rectangular area, only square area.
Discussion from others is requested and welcome before any action is taken. Are these worthwhile to others?
Thanks
Fred
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Request Enhancments Similar to -mode
-min -max -mean are morphology operators erode, dilate, convolve.
Just specify the appropriate neighbourhood and channels
You can also use ErodeIntensity and DilateIntenasity
to select the color (whole pixel) based in the color intensity. (You can't get a -mean with intensity)
It was median the is very different (middle intensity of all pixels in neighbourhood).
Just specify the appropriate neighbourhood and channels
You can also use ErodeIntensity and DilateIntenasity
to select the color (whole pixel) based in the color intensity. (You can't get a -mean with intensity)
It was median the is very different (middle intensity of all pixels in neighbourhood).
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Request Enhancments Similar to -mode
anthony wrote:-min -max -mean are morphology operators erode, dilate, convolve.
Just specify the appropriate neighbourhood and channels
You can also use ErodeIntensity and DilateIntenasity
to select the color (whole pixel) based in the color intensity. (You can't get a -mean with intensity)
It was median the is very different (middle intensity of all pixels in neighbourhood).
Thanks, I accidentally used close and open rather than dilate and erode in my script. Hopefully that will fix it. But I want to be sure that in
-morphology erode/dilate square:radius
is radius just the size/2 (+1?) for a square. If I want the size to be 32, would I use radius of 16 or 17 or something else?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Request Enhancments Similar to -mode
Square:r is a square r*2+1 with the origin centered.
See http://www.imagemagick.org/Usage/morphology/#square
Also look at rectangle!
See http://www.imagemagick.org/Usage/morphology/#square
Also look at rectangle!
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Request Enhancments Similar to -mode
Thanks, but still very slow compared to using -blur radiusx65000 to get mean. But there ought to be similar functions to get min, max, mean, standard-deviation, mode and other statistical operations on a rectangle that run faster than -morphology erode/dilate square:radius
Fred
Fred
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Request Enhancments Similar to -mode
The -blur may be used some GPU processing for ultra fast processing.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Request Enhancments Similar to -mode
anthony wrote:The -blur may be used some GPU processing for ultra fast processing.
But I need something similar to -blur for getting min and max in a region.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: Request Enhancments Similar to -mode
Then your choices are either use morphology, or a dedicated (less neighbourhood controlled) MagickCore function for speed.
Aside. I want to make the change to Blur so that by default it understands transparency (no haloing).
To do this I would make -channel sync flag (turned on by default and means synchronize channel handling) perform what is current enabled using -channel RGBA
This will however mean that -channel RGBA (which turns off sync) will blur each channel separately and thus
could produce black transparency halos.
Basically it will bring the operator more in line with other operators, like -auto-level, -morphology, and the mathematical composition methods.
Aside. I want to make the change to Blur so that by default it understands transparency (no haloing).
To do this I would make -channel sync flag (turned on by default and means synchronize channel handling) perform what is current enabled using -channel RGBA
This will however mean that -channel RGBA (which turns off sync) will blur each channel separately and thus
could produce black transparency halos.
Basically it will bring the operator more in line with other operators, like -auto-level, -morphology, and the mathematical composition methods.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Request Enhancments Similar to -mode
I withdraw my request. Seems for now, that -morphology and -blur achieves most of what I need.
Fred
Fred
Re: Request Enhancments Similar to -mode
Too late. -statistic {median, mode, minimum, maximum, nonpeak} has already been added to ImageMagick 6.6.8-6 Beta available by sometime tomorrow.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Request Enhancments Similar to -mode
Sorry you went to the trouble. I did not think you were going to implement anything until after discussions had finished. But since you have. Thanks.magick wrote:Too late. -statistic {median, mode, minimum, maximum, nonpeak} has already been added to ImageMagick 6.6.8-6 Beta available by sometime tomorrow.
But what about the dimensions argument? How does that work to specify the type of stats and the widthxheight? What is the syntax? What is non-peak? Also what about average (mean)? Or are you leaving that to -blur radiusx65000? And also standard-deviation? I guess these can come later.
Other variations can be found in the listings for my statsfilt script at http://www.fmwconcepts.com/imagemagick/ ... /index.php, but I don't mean to suggest you necessarily implement any or all. But your implementation opens the door for other noise filtering variations such as in my script. Some of these require further arguments that may not fit into the current IM argument parsing.
Another good one, that I did not implement in my script is called kth nearest neighbor average. If you are so inclined, it averages the k (user supplied) pixels whose values are closest to the value of the center pixel along with the center pixels. However, the extra argument k, may not fit well with your current argument parsing!
Fred
Re: Request Enhancments Similar to -mode
Baby steps. The first release handles a neighborhood of widthxwidth.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Request Enhancments Similar to -mode
magick wrote:Baby steps. The first release handles a neighborhood of widthxwidth.
Right. Just curious about the syntax.
Re: Request Enhancments Similar to -mode
Ok, we're supporting width x height afterall.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Request Enhancments Similar to -mode
-statistic seems to be working correctly now in IM 6.6.8.10 Q16. Thanks.
This is not urgent, But at some point when you get time, could you possibly add standard-deviation. Here is one method that I have used. But do it any way you want.
For each channel:
1) Compute sum of graylevel and divide by N to get average
2) compute sum of graylevel^2 and divde by N to get average
3) Compute std = sqrt (variance) = sqrt( ave(g^2) - (ave(g))^2 )
see
http://en.wikipedia.org/wiki/Standard_deviation
http://en.wikipedia.org/wiki/Variance
Thanks
Fred
This is not urgent, But at some point when you get time, could you possibly add standard-deviation. Here is one method that I have used. But do it any way you want.
For each channel:
1) Compute sum of graylevel and divide by N to get average
2) compute sum of graylevel^2 and divde by N to get average
3) Compute std = sqrt (variance) = sqrt( ave(g^2) - (ave(g))^2 )
see
http://en.wikipedia.org/wiki/Standard_deviation
http://en.wikipedia.org/wiki/Variance
Thanks
Fred