How to read image from pixel values

Hi,
How to find the mean value of pixels of 10 images
Thanks in advance

 Accepted Answer

Your title does not appear to be asking the same thing as your question ??
Are you reading 10 images all exactly the same size, and you want to get a per-pixel mean across the 10 images? If so then provided that the images are gray-scale, use
mean(cat(3,IMG1,IMG2,IMG3,IMG4,IMG5,IMG6,IMG7,IMG8,IMG9,IMG10),3)
If the images are pseudocolor, then you need to use the associated colormap and ind2rgb() to convert them to RGB before you can find the mean.
If you are working with truecolor (RGB -- separate red, green, and blue pixel values), then you need to decide whether you want the mean intensity (brightness) or if you want a mean per color channel. If you want a mean intensity, use rgb2gray() and then the mean() that I showed earlier. If you want a mean per color channel, then
mean(cat(4,IMG1,IMG2,IMG3,IMG4,IMG5,IMG6,IMG7,IMG8,IMG9,IMG10),3)
(I think.)
Warning: the process of taking the mean() will leave you with a double-precision array, even if your input arrays were uint8. If your input arrays were not already double-precision, then you will not be able to directly display or imwrite() the output. You will probably want to cast() the output of the mean to class(IMG1), as in
cast(mean(cat(3, IMG1, IMG2, IMG3, IMG4, IMG5, IMG6, IMG7, IMG8, IMG9, IMG10),3), class(IMG1))

6 Comments

what is cat in this command
http://www.mathworks.com/help/techdoc/ref/cat.html
Concatenate arrays along specified dimension
Hi,
I have 10 images of gray scale ,I applied this coomand for them
But not working
can u suggest something about this?
thanks in advance
Please indicate what happens when you say it is "not working".
Please show the size() of one of the images, and please check that the size() of the other images is exactly the same. Please also indicate class() of one of the images, and please check that the class() of the other images is exactly the same.
Hi,
I got the mean by using the command for gray scale image
In that command you used 3 dimensional
when using 2 dimensional I am not getting the answer.why?
Thanks in advance
If you have several 2 dimensional images, then you can stack them on the 3rd dimension and then take the mean along that 3rd dimension to have a 2d result for each location. It is important that the first number in the cat() call be one more than the number of dimensions in your image.

Sign in to comment.

More Answers (0)

Categories

Find more on Images in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!