why I use imread fuction this photo not RGB array?
9 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
temp = imread('image.png');
% temp = 3000x4000 uint8?
why this photo don't have RGB 3D-array?
because I use pixelLabelDatastore function. then show result
Pixel label image must have 3 channels when RGB-triplet pixel label IDs are specified.
L = matlab.io.datastore.PixelLabelDatastore.label2cat(...
C = this.label2categorical(C, info);
It let me check the photo, why don't have rgb 3d array?

0 comentarios
Respuesta aceptada
DGM
el 18 de Sept. de 2023
It's an indexed-color image. If you want it to be RGB, you can convert it.
% this is an indexed image and its corresponding color table
[inpict map] = imread('https://www.mathworks.com/matlabcentral/answers/uploaded_files/1485727/image.png');
% convert it to RGB
inpict = ind2rgb(inpict,map);
size(inpict)
imshow(inpict,'border','tight')
See also:
2 comentarios
DGM
el 19 de Sept. de 2023
Editada: DGM
el 19 de Sept. de 2023
I don't have CVT, so I'm not familiar with pixelLabelDatastore, but I think the way labelIDs are specified depends on the type of each image.
If it's an RGB image, they're specified as a color table, but if the file is indexed color, the labels are specified as the index.
% do it with an RGB input
classes = {'a','b','c','d','e','f'};
labelIDs = [0 0 0; 102 102 156; 128 64 128; 107 142 35; 0 0 142; 70 70 70];
pxds = pixelLabelDatastore('./',classes,labelIDs);
A = readimage(pxds,2);
size(A)
unique(A)
% do it with an indexed input
classes = {'a','b','c','d','e','f'};
labelIDs = 0:5;
pxds = pixelLabelDatastore('./',classes,labelIDs);
A = readimage(pxds,1);
size(A)
unique(A)
If the image type or classes vary within a directory, I see no way to handle that.
Más respuestas (0)
Ver también
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
