How can i check if an image is RGB or grayscale or binary?
Mostrar comentarios más antiguos
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 comentarios
Jagdish
el 24 de Abr. de 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
el 27 de Jul. de 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
el 27 de Jul. de 2018
@Sky Dutta: read the comments to the accepted answer.
Respuesta aceptada
Más respuestas (2)
Walter Roberson
el 18 de Ag. de 2012
0 votos
Use rgb2gray() to convert the image to grayscale.
Noor Ul Islam
el 27 de Dic. de 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
Categorías
Más información sobre Images en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
