# the size of picture show three data?

2 views (last 30 days)
bozheng on 16 Jan 2024
Answered: Image Analyst on 16 Jan 2024
As shown in the figure, I found that the call size results have three photos, but the question is how to view only one photo
the 20230814.jpg is below
So why multiply by 3? Any complete argument or reason? Thank you for your enthusiastic answers.

John D'Errico on 16 Jan 2024
Edited: John D'Errico on 16 Jan 2024
A black and white image typically has one channel only. All you need to know is how bright each pixel is.
But a color image stores typically red, green and blue channels. (Other color spaces can also be used of course.) But THREE channels. The jpeg image you show is a color image. Each pixel is represented by its corresponding red, green and blue code values.
Steven Lord on 16 Jan 2024
John is exactly correct. For example, consider the peppers.png file.
whos imagedata colormapdata
Name Size Bytes Class Attributes colormapdata 0x0 0 double imagedata 384x512x3 589824 uint8
Because the colormapdata variable is empty, that means imagedata has three planes of data: red, green, and blue. If we look at the image as a whole we can see all the colors.
figure
imshow(imagedata)
title('All channels')
But if we show just one channel, we only see that color. In the red channel, the green peppers are somewhat dark.
imagedataRed = imagedata;
imagedataRed(:, :, 2:3) = 0; % zero out the green and blue
figure
imshow(imagedataRed)
title('Red channel')
In the green channel, the red peppers are somewhat dark.
imagedataGreen = imagedata;
imagedataGreen(:, :, [1 3]) = 0; % zero out the red and blue
figure
imshow(imagedataGreen)
title('Green channel')
In the blue channel, both red and green peppers are dark. There aren't any blue peppers, but the white onions still show up somewhat.
imagedataBlue = imagedata;
imagedataBlue(:, :, 1:2) = 0; % zero out the red and green
figure
imshow(imagedataBlue)
title('Blue channel')

Dyuman Joshi on 16 Jan 2024
It does not result in 3 images. That is a single image only, which is stored as a 3D array.
That is a RGB image, also referred as Truecolor image, stored as mxnx3 array.
Each page/plane of the array contains information regarding color intensity - the first plane in the third dimension represents the red pixel intensities, the second plane represents the green pixel intensities, and the third plane represents the blue pixel intensities.

Image Analyst on 16 Jan 2024
The two others said why the size is 3 times the size of the lateral dimensions (because you have 3 color channels/planes).
Don't use "image" as the name of your variable since that is a built-in function name.
You will need to define img1. You use it in your code but you don't define it. You only define img, not img1, at least in what you've shown us.

### Categories

Find more on Image Arithmetic in Help Center and File Exchange

R2020a

### Community Treasure Hunt

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

Start Hunting!