Clear Filters
Clear Filters

the size of picture show three data?

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

Accepted Answer

John D'Errico
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.
  1 Comment
Steven Lord
Steven Lord on 16 Jan 2024
John is exactly correct. For example, consider the peppers.png file.
[imagedata, colormapdata] = imread('peppers.png');
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.
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
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
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
title('Blue channel')

Sign in to comment.

More Answers (2)

Dyuman Joshi
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
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.




Community Treasure Hunt

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

Start Hunting!