How to find out matlab image type

This question may be very simple, but please come with me.

When I use imread in matlab and read the image, how would I know if it will be rgb, gray scale or single programmatically? Your help is greatly appreciated. I tried searching on the Internet, but I don’t know what word or phrase I have to enter in order to see how exactly Wat is looking. Thank you in advance. anyone can program the link or the corresponding term, which would be really helpful.

I1 = imread('sample_image.jpg'); 

How can I find out what type I1 is before any conversion?

+6
source share
1 answer

You can use imfinfo to get information about the image file before downloading it:

 info = imfinfo('sample_image.jpg'); info.ColorType % eg 'grayscale', 'truecolor', 'indexed' info.BitDepth % eg 8, 16 

You can also look at the imread help topic to find out which output class will be used for different file types. The problem is to determine the difference between the grayscale image and the indexed color file - they will have the same size and class. In this case, you need to check ColorType and load the color map when viewing the image:

[I, map] = imread(filename)

+8
source

Source: https://habr.com/ru/post/952248/


All Articles