choosing locations in an image to take pixels

2 views (last 30 days)
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

Image Analyst
Image Analyst on 26 Jul 2014
meanGrayLevel = mean(grayImage(:)); % Take mean of entire image.
  3 Comments
Rick
Rick on 26 Jul 2014
Edited: Rick on 26 Jul 2014
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.
Image Analyst
Image Analyst on 26 Jul 2014
meanh = mean2(hsv_image(:,:,1));
means = mean2(hsv_image(:,:,2));
meanv = mean2(hsv_image(:,:,3));

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!