JPG to RGB image?
Afficher commentaires plus anciens
I'm using a method that requires an rgb image as input. I tried
[cdata,map] = imread('face.jpg' )
cdata = ind2rgb( cdata, map );
to get that rgb image in cdata. However, map is always empty, no matter what image I try (jpg, tif, or bmp), resulting in the error "Index exceeds matrix dimensions." cdata is an mxnx3 matrix, I expected it to be just an mxn matrix?
I have no idea how to get my rgb image. Any help would be greatly appreciated!
Réponses (2)
David Young
le 5 Déc 2011
0 votes
JPEG images are read directly as rgb - so there's no map. So you don't need the call to ind2rgb (or the second result from imread). The reason the third dimension of cdata is 3 is that it is already rgb.
Tessa
le 5 Déc 2011
1 commentaire
David Young
le 5 Déc 2011
The expression
(not (ismatrix(im)) || not (ndims (im) == 3))
is true for all values of im. It doesn't matter what im is, the function will always throw an error.
I guess you should probably just omit the first part of the test, so you have
if not(ndims(im) == 3)
Catégories
En savoir plus sur Images dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!