Color and brightness in imread
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Nahyun Kim
am 15 Jul. 2019
Bearbeitet: KALYAN ACHARJYA
am 15 Jul. 2019
While testing a program in Matlab, there kept being errors about arrays generated by imread not having 3 layers (ie, when the command was imshow(imgarray(:,:,1); the interpreter gave the error "Index exceeds matrix dimensions." I decided to test imread's capabilities with the following image, but Matlab seemed to interpret it as a 1-layer greyscale image rather than a color image with three color channels. How do I make Matlab read the image like it is in color when it defaults to black and white?
4 Kommentare
Stephen23
am 15 Jul. 2019
Bearbeitet: Stephen23
am 15 Jul. 2019
"Is there a way to specify how the file is stored or how it is imported into matlab?"
Yes, it is easy to find out how the image is stored (in an image file), and how to import it into MATLAB. See my answer. KALYAN ACHARJYA's answer is completely unrelated to your indexed image.
Akzeptierte Antwort
Stephen23
am 15 Jul. 2019
Bearbeitet: Stephen23
am 15 Jul. 2019
Your image is actually an indexed image, not a grayscale image, and this is easy to find out using the inbuilt imfinfo:
>> imfinfo('rgbtest.png')
ans =
Filename: 'C:\Users\stephen.cobeldick\Documents\MATLAB\working\rgbtest.png'
FileModDate: '15-Jul-2019 18:23:52'
FileSize: 3482
Format: 'png'
FormatVersion: []
Width: 800
Height: 600
BitDepth: 8
ColorType: 'indexed' % <------ LOOK HERE!
FormatSignature: [137 80 78 71 13 10 26 10]
Colormap: [256x3 double]
Histogram: []
... etc.
Indexed images are trivial to work with, once you have the corresponding colormap:
>> [im,map] = imread('rgbtest.png');
>> imshow(im,map)
>> rgb = ind2rgb(im,map);
The MATLAB documentation has a very good explanation of different image types (e.g. indexed, RGB, grayscale):
2 Kommentare
KALYAN ACHARJYA
am 15 Jul. 2019
Bearbeitet: KALYAN ACHARJYA
am 15 Jul. 2019
Thank you @Stephen for pointing my mis-conception.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!