attempt to execute rgb2gray but showing error
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Here's my code
clc; %rgb2gray
a=imread('2.jpg');
c=rgb2gray(a);
f=double(c);
[row, col, dim]=size(f);
b=255;
g=b-c;
subplot(2,2,1);
imshow(a);
title('original image');
subplot(2,2,2);
imshow(c);
title('rgb2gray');
subplot(2,2,3);
colormap(gray);
imshow(g);
title('negative image');
The error message is :
Error in rg (line 3)
c=rgb2gray(a);
1 Commento
Steven Lord
il 15 Apr 2019
That's not the full text of the error message. Show us all the text displayed in red.
Risposte (1)
Image Analyst
il 15 Apr 2019
Replace this:
a=imread('2.jpg');
c=rgb2gray(a);
f=double(c);
[row, col, dim]=size(f);
with this:
a = imread('2.jpg');
[row, col, numberOfColorChannels] = size(a)
if numberOfColorChannels == 3
% Convert only if color
grayImage = rgb2gray(a);
else
grayImage = a;
end
f=double(grayImage);
0 Commenti
Vedere anche
Categorie
Scopri di più su Lighting, Transparency, and Shading in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!