I know you all are busy, so this is not a high priority, but a when you can request (or add to enhancement list) as there are workarounds, but I use them frequently when doing scripting. Would it be possible to add a few more string formats to the list you have to be able to retrieve the min, max, mean and standard deviation from an image channel or a grayscale image? These could potentially be %L, %H, %M and %S (or whatever you want) so that I could do something like:
mean=`convert <rgbimage> -channel Red -separate -format "%M" info:`
mean=`convert <grayscaleimage> -format "%M" info:`
to get and store the mean of the image, etc for std and min and max.
Or however that would be implemented appropriately.
Thanks for considering this.
Fred
P.S. My workaround for a grayscale image is as follows (with help from Anthony):
function imagestats
{
data=`convert $infile -verbose info:`
min=`echo "$data" | sed -n '/^.*Min:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
max=`echo "$data" | sed -n '/^.*Max:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
mean=`echo "$data" | sed -n '/^.*Mean:.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
std=`echo "$data" | sed -n '/^.*Standard.*[(]\([0-9.]*\).*$/{ s//\1/; p; q; }'`
}
Requested Enhancement To List of String Formats
Re: Requested Enhancement To List of String Formats
The following enhancements are available in ImageMagick 6.3.9-1 Beta:
- convert image.jpg -format '%[mean]' info:
convert image.jpg -format '%[standard-deviation]' info:
convert image.jpg -format '%[min]' info:
convert image.jpg -format '%[max]' info:
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Requested Enhancement To List of String Formats
Wow! That was fast? You are terrific!
What happens if the image is RGB not grayscale? Do you get multiple values that need to be separated?
Not to look a "gift-horse" in the mouth, but would it make sense to shorten the %[standard-deviation] to %[std] (for less typing) or do you think that would not be understood by most people?
What happens if the image is RGB not grayscale? Do you get multiple values that need to be separated?
Not to look a "gift-horse" in the mouth, but would it make sense to shorten the %[standard-deviation] to %[std] (for less typing) or do you think that would not be understood by most people?
Re: Requested Enhancement To List of String Formats
The ImageMagick designer preference is to use descriptive names whenever possible as a form of self-documenting. We documented the names in the web pages under -format.
The values returned are based on the setting of -channel. If you do not set -channel, you get the mean, for example, for red, green, and blue combined.
The values returned are based on the setting of -channel. If you do not set -channel, you get the mean, for example, for red, green, and blue combined.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Requested Enhancement To List of String Formats
Thanks. I understand with regard to your naming conventions. I will test this out at my earliest possibility. I look forward to using it. Thanks for the heads-up about the -channel setting. This should work just fine.