필터 지우기
필터 지우기

the size of picture show three data?

조회 수: 3 (최근 30일)
bozheng
bozheng 2024년 1월 16일
답변: Image Analyst 2024년 1월 16일
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
John D'Errico 2024년 1월 16일
편집: John D'Errico 2024년 1월 16일
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
Steven Lord
Steven Lord 2024년 1월 16일
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.
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')

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Dyuman Joshi
Dyuman Joshi 2024년 1월 16일
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 2024년 1월 16일
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.

태그

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by