Why is Imread returning a 3 dimensional matrix when reading a grayscale image?
7 views (last 30 days)
Show older comments
I used avitoframe to segment an avi file into png images frame by frame. The video parameters are listed as RGB24. However, when I do imread of the frame, the frame seems to be a grayscale image because the pixel values seem to be between 0 and 255. My first question is why is an RGB video returning grayscale values.
My second question is if the matrices returned from imread are grayscale intensity values, why do I have a 3 dimensional matrix for the frame. For some videos, the 3 pages of the 3 D matrix are equal. However, for other videos, the first and last page are equal and the second page is 2 values less than the first page.
2 Comments
GEEVARGHESE TITUS
on 24 Feb 2017
RGB24 format is an RGB video format where each pixel is composed of one byte of red, green and blue components, taking upto 24 bits, hence the name. If the image has three planes, it corresponds to a color image. Just to validate we are able to get a back color by using all the planes(RGB) are zeros and white if the planes(RGB) are ones. Likewise we will be able to get other shades of grey. An actual grey scale image will have only one plane.
Walter Roberson
on 24 Feb 2017
In color theory, white is composed of equal parts of all other colors. It happens that when RGB was defined, they used the same rule, that equal values of the pixel components would lead to white, and the different pixel intensities at equal values would lead to different brightnesses of white.
In a situation where the R and B panes are equal but the G plane is less, then the perceived color might still fall into what we broadly call white. We are not too particular about naming colors.
Answers (0)
See Also
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!