JPG to RGB image?
古いコメントを表示
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!
回答 (2 件)
David Young
2011 年 12 月 5 日
0 投票
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
2011 年 12 月 5 日
1 件のコメント
David Young
2011 年 12 月 5 日
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)
カテゴリ
ヘルプ センター および File Exchange で Images についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!