Page 1 of 1

Weight of an image

Posted: 2008-08-19T12:34:54-07:00
by vadimiron
I have two or more images and i need to find out which one has the biggest weight and to which extension. The image with the biggest weight will be noticed by a human as first, then the image with less weight ans so on. Should i use saturation or luminosity?? And how could such comparision with imagemagick?

Thank you in advance!

Re: Weight of an image

Posted: 2008-08-19T13:40:39-07:00
by vadimiron
How could i calculate a mean luminosity of an image???

Re: Weight of an image

Posted: 2008-08-19T14:46:55-07:00
by fmw42
I am not sure I understand what you mean by "weight". Is that brightness, intensity, luminance or some other?

Luminosity is not a good term. See http://en.wikipedia.org/wiki/Luminosity

Choose a colorspace for what you want based upon the formulae at:
See http://www.imagemagick.org/script/comma ... colorspace


See fx for luminance, etc at http://www.imagemagick.org/script/fx.php
and fx escapes at http://www.imagemagick.org/Usage/transform/#fx_escapes

Thus there are many choices:

convert rose: -colorspace gray -format "%[fx:mean]" info:
convert rose: -colorspace rec601luma -format "%[fx:mean]" info:
convert rose: -colorspace rec709luma -format "%[fx:mean]" info:
convert rose: -colorspace yiq -channel r -separate -format "%[fx:mean]" info:

You might want to look at my tidbits page at http://www.fmwconcepts.com/imagemagick/ ... e_info.php for various ways to compute the average or mean value of an image.

Re: Weight of an image

Posted: 2008-08-19T15:52:39-07:00
by vadimiron
Thank you!

and can i calculate the mean values for brightness, intensity, too???

Re: Weight of an image

Posted: 2008-08-19T17:10:57-07:00
by fmw42
brightness has a specific meaning in IM as it relates to the colorspace HSB which is a hexcone colorspace, where brightness = max(r,g,b). intensity is the same as -colorspace gray. you can see all these by comparing formulae from the page for fx http://www.imagemagick.org/script/fx.php where it says:

intensity: pixel intensity; equivalent to 0.299*red+0.587*green+0.114*blue
lightness: pixel lightness; equivalent to 0.5*max(red,green,blue) + 0.5*min(red,green,blue)
luminance: pixel luminance; equivalent to 0.2126*red + 0.7152*green + 0.0722*blue

to those listed on the page for colorspace at http://www.imagemagick.org/script/comma ... colorspace

Gray = 0.29900*R+0.58700*G+0.11400*B
HSB brightness=max(R,G,B);
Rec601Luma Gray = 0.29900*R+0.58700*G+0.11400*B
Rec709Luma Gray=0.21260*R+0.71520*G+0.07220*B
YCC, YIQ, YUV Y=(0.29900*R+0.58700*G+0.11400*B)

Thus Gray (from -colorspace Gray), Intensity, Rec601Luma and Y from YCC, YIQ, YUV are all the same. Similarly luminance and Rec709Luma are the same.

Lightness=(max(r,g,b)+min(r,g,b))/2 (average of highest and lowest values channel values)
Brightness=max(r,g,b) (just the highest channel value)

You can get the mean for any, either directly or by separating out the appropriate channel first, as in my examples in my last post, depending upon which one you want.

Re: Weight of an image

Posted: 2011-12-11T14:19:57-07:00
by rai037
Can any one tell plz? what a weight means? i need it for image processing stuff...

Re: Weight of an image

Posted: 2011-12-11T15:27:37-07:00
by fmw42
Are you talking about weight as filesize in (kbytes)?

Filesize can be computed as

convert image -format "%b" info:

see http://www.imagemagick.org/script/escape.php