Image into grayscale without using toolbox
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Krish Desai
am 12 Okt. 2015
Kommentiert: Krish Desai
am 12 Okt. 2015
This is my current code:
function out = luminance(current_img )
R=current_img(:,:,1);
G=current_img(:,:,2);
B=current_img(:,:,3);
I=.299*R + 0.587*G+0.114*B;
out=I;
end
I'm trying to make my image grayscale but that's not what's happening, what am I doing wrong?
0 Kommentare
Akzeptierte Antwort
Image Analyst
am 12 Okt. 2015
That should work. What's the problem? Perhaps you want to cast it back to uint8 or something.
out = uint8(.299*double(R) + 0.587*double(G)+0.114*double(B));
or else just leave it as floating point and use [] in imshow to display it:
imshow(out, []);
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Image Processing Toolbox finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!