A Site for Photographers by Photographers

Community > Forums > Digital Darkroom > Imaging Techniques>Other > How to determine the average...

Featured Equipment Deals

4 Current Trends in Engagement Photography Read More

4 Current Trends in Engagement Photography

Photographer and author Stephanie Williams discusses four current engagement photography trends.

Latest Equipment Articles

Choosing a Mobile Photo Printer Read More

Choosing a Mobile Photo Printer

In today's mobile, digital world, we carry hundreds or even thousands of pictures around on our smartphones and tablets. Tom Persinger looks at 4 different mobile photo printer options for getting...

Latest Learning Articles

Advanced Printing with Lightroom (Video Tutorial) Read More

Advanced Printing with Lightroom (Video Tutorial)

Building upon last week's Basic Printing with Lightroom video tutorial, this advanced printing tutorial will teach you to print contact sheets, print multiple images at a time, use Lightroom's present...


How to determine the average color over a selection

Paul Hutson , Jan 17, 2003; 04:32 p.m.

I am trying to determine the "redness" of a person's palm and sole by evaluating digital images using L*a*b values. Is there a way in Photoshop or another program to average the L*a*b values over a selected area (eg., entire palm) rather than just a 3 pixel area (dropper)? Thanks Paul UW School of Pharmacy

Responses

Andy Piper , Jan 17, 2003; 05:08 p.m.

Response to Image color averaging

Well, one way would be to reduce the image resolution drastically (on a COPY of the image file!) so that the palm or sole is reduced to a single pixel (or a 3x3 array). In resampling the image Photoshop will come up with an 'average' value from all the previous pixels, which you can then measure with the eyedropper.

Actually you'd probably want the final pixel to be just slightly smaller than the sole/palm, to avoid picking up any color or brightness values, in the 'average', from the surrounding background.

There's also a 'pixellate' filter that will do roughly the same thing (but creating bigger squares instead of reducing the image file size).

In either case you'll have to experiment a bit (with liberal use of the "undo" command) to find settings for image size or pixel size that work best for the image you're starting with.

Emre Safak , Jan 17, 2003; 05:14 p.m.

Response to Image color averaging

Select the region and apply a strong Gaussian blur.

Jim S , Jan 17, 2003; 06:40 p.m.

The eyedropper has the ability to average to some degree.

Andy Piper , Jan 18, 2003; 09:04 p.m.

I just tested Emre's suggested technique - but while the "strong gaussian blur" only CHANGES the pixels within the selected area, it does pick up tones/colors from outside the selected area (but within the blur radius) as part of the blurred tone, which could throw off color measurements.

See example


Blurred selection influenced by outside tones

Andy Piper , Jan 18, 2003; 09:49 p.m.

Example shows the back of a hand, not the palm, but the principle applies.

I used the 'pixellate/mosaic' filter over that part of the image - each 'pseudopixel' or 'superpixel' created averages the tones within it. You can vary the size of the superpixels when applying the filter to get the best fit to your image. A 10x10 array will average 1000 pixels into 10, cutting the number of measurements you need to make by a factor of 100. Photoshop will do at least 95% of the work for you.

As with Emre's technique the pixels near the edge pick up some contamination from colors/tones outside the hand - so assume they are 'bad data'.


Attachment: handtest.jpg

Emre Safak , Jan 19, 2003; 02:40 p.m.

Andy is certainly on the ball, but I am not going to be trumped by him :P

I tested my method too and he is right. I have good news and I have bad news. The good news is that I found a way to avoid the problem. The bad news is that the selection has to be rectangular unless you use a supporting application. Make your selection using the "rectangular marquee" tool. Copy it and paste it into a new document. Apply Gaussian blur with maximum radius. This time fringing won't occur because there is no fringe :)

There is a better way if you have MATLAB. Save your selection (ensuring the rest is transparent) as a PNG or TIFF into a separate file and run the following commands in MATLAB:


img=imread('selection.png');
vec=reshape(img,prod(size(img))/3,3);
ind=find(sum(vec,2));
average(vec(ind,:));

N.B.: You might need to change directory first with CD.

What we do here is to convert the image matrix into a vector. Then we discard the background (zeros in the matrix) and find the average of what is left. The 'average' function does not exist -- you have to define it to implement your definition of "average".

Paul Hutson , Jan 20, 2003; 11:15 a.m.

Andy and Emre, you two are amazing. Thanks very much for your excellent ideas. I think that, with no MATLAB experience, I will try the Photoshop export/Gaussian blur that Emre suggests. The MATLAB online manual suggests that the vector used is RGB, which raises another issue (posted as a new thread) about the "best" measure of redness, and whether one scale is better than another (eg., linear) for making statistical comparisons of "redness". Thank you very much. Paul

Emre Safak , Jan 20, 2003; 11:24 a.m.

Perhaps I should have touched upon that. You can convert between RGB and HSV by using rgb2hsv and hsv2rgb. A similar conversion is possible between RGB and Lab. Now you can take your pick. Obviously you still need to define a metric!

Back to top

Notify me of Responses