by using the function:
MAT=imread('image.jpg');
sometimes (if the image isn't in grayscale) i get output of 3D matrix (RGB) is there any function or a technic i can use?

1 件のコメント

Sara
Sara 2014 年 7 月 1 日
Can use to do what?

サインインしてコメントする。

 採用された回答

the cyclist
the cyclist 2014 年 7 月 1 日

2 投票

numel(size(MAT))>=3
will be true for an array of dimension 3 or greater.
Note that this will not discriminate between objects of dimension 1 and 2, because of how MATLAB stores scalars as vectors of length 1 (and therefore have size 1x1).

その他の回答 (1 件)

Geoff Hayes
Geoff Hayes 2014 年 7 月 1 日

5 投票

Try ndims which returns the number of dimensions
if ndims(MAT)==3
% matrix is three dimensional
end

2 件のコメント

the cyclist
the cyclist 2014 年 7 月 1 日
I didn't know about this command, which is a cleaner version of what I did more manually. Note that it suffers from the same weakness about not being able to discriminate between objects of dimension 1 and 2.
Geoff Hayes
Geoff Hayes 2014 年 7 月 1 日
編集済み: Geoff Hayes 2014 年 7 月 1 日
That's true. You could use isvector to discriminate between objections of dimension 1 and 2.
I suppose even ismatrix could be used to determine if the object has at most two dimensions (and so ~ismatrix(MAT) would be true for a 3D image).

サインインしてコメントする。

製品

質問済み:

2014 年 7 月 1 日

編集済み:

2014 年 7 月 1 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by