Re: Calculating the "Mean" of a histogram...
Re: Calculating the "Mean" of a histogram...
- Subject: Re: Calculating the "Mean" of a histogram...
- From: "Bruce J. Lindbloom" <email@hidden>
- Date: Tue, 05 Aug 2003 09:40:54 -0500
Carl Stawicki wrote:
>
I'm working on an AppleScript that will calculate the Mean value of a
>
channel's histogram. The Mean is the average intensity value, and I'm giving
>
myself a headache trying to figure out the math.
Just add up the pixel values and then divide the result by the number of
pixels. For example, if you had an image that was two pixels by two pixels,
there are four total pixels:
68 175
112 29
The mean would be (68 + 175 + 112 + 29) / 4 = 96.
But something you must watch out for is that most images are larger than 2 x
2 pixels, and in fact may easily be MUCH larger than 2 x 2 pixels. So the
sum of all pixel values could be a very large number, and depending on the
data type that is used to store it, it may overflow which would yield the
wrong result. If a 32-bit signed integer was used for the sum with an 8-bit
per channel image, an overflow could occur with an image larger than 2900 x
2900 pixels. If you are working with 16-bit channels, the scenario is much
worse (180 x 180). You should probably use floating point, if the scripting
allows that sort of control (sorry, I'm not an AppleScript guy).
--
Bruce J. Lindbloom
email@hidden
http://www.brucelindbloom.com
_______________________________________________
colorsync-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/colorsync-users
Do not post admin requests to the list. They will be ignored.