choosing locations in an image to take pixels

Hello,
If I take an image and I want to do an average of the pixels across the entire image, how do I do that? Right now when I do imshow(image) then it gives me locations where I click on the image. I just want to do the entire image.
Thanks

 Accepted Answer

meanGrayLevel = mean(grayImage(:)); % Take mean of entire image.

3 Comments

Or
meanGrayLevel = mean2(grayImage); % Take mean of entire image.
what if the image is not gray? I take the image as RGB, then convert it to HSV, then take the HSV average.
This is what I have
RGB = imread(image);
hsv_image = rgb2hsv(RGB);
imshow(hsv_image);
pixel_values = impixel(hsv_image);
AverageHSV = mean(pixel_values);
When I do this command a figure appears with the image, and I have to manually click on points. I just want the entire image to automatically be averaged instead of the points that I click. I would like it to be a 1 by 3 array with average H, average S, and average V over the whole image.
meanh = mean2(hsv_image(:,:,1));
means = mean2(hsv_image(:,:,2));
meanv = mean2(hsv_image(:,:,3));

Sign in to comment.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Asked:

on 26 Jul 2014

Commented:

on 26 Jul 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!