How can i check if an image is RGB or grayscale or binary?
Show older comments
I'm a new in matlab, need answer to this question.. And, may i change the size of matrix of RGB image to two-dimensional matrix? I wanna try edge detection, i load an grayscale image but the image matrix show an image have three-dimensional matrix.. Any solutions?? Thank you for your response..
3 Comments
Jagdish
on 24 Apr 2014
%% You can check if an image is RGB or grayscale or binary? by using imagemodel1 function.... as shown below
|Im = Imread ( xyz..... ); handle = image(Im); imgmodel = imagemodel(handle); str = getImageType(imgmodel)
Sky Dutta
on 27 Jul 2018
How can i get to know that the image is rgb? I mean I need a program which tell me that "This image is Colored image or this is a binary image"?
Stephen23
on 27 Jul 2018
@Sky Dutta: read the comments to the accepted answer.
Accepted Answer
More Answers (2)
Walter Roberson
on 18 Aug 2012
0 votes
Use rgb2gray() to convert the image to grayscale.
Noor Ul Islam
on 27 Dec 2013
% first Read image
img=imread('imag.jpg');
% Check img whether it rgb or grayscale
[r c d]=size(img)
% if image is 3D above command will give an error; solution=remove o/p variable d, then it is %perfect
% to convert to grayscale
% use inbuilt command
img1=rgb2gray(img); %now you get 2D image
% to manipulate the true colors RGB; split image into R,G,B components as follow
R=img(:,:,1);
G=img(:,:,2);
B=img(:,:,3);
%Note: each R,G and B component is 2D matrix... hope this is what u required
Categories
Find more on Color in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!