How to convert a color of image to green?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have this code for converting it to red
if true
I= imread('1.tif');
R = I(:,:,1);
image(R), colormap([[0:1/255:1]', zeros(256,1), zeros(256,1)]), colorbar;
end
I changed the number 1 to 2 or 3 I got this message
Index in position 3 exceeds array bounds (must not exceed 1).
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/190574/image.jpeg)
0 Kommentare
Antworten (1)
Jan
am 15 Mai 2018
Bearbeitet: Jan
am 15 Mai 2018
The error message means, that the imported image is a grey scale image, such that I is a 2D matrix, not a 3D RGB array. If it is not an indexed image, the colorbar does not affect anything.
Try this:
R = cat(3, zeros(size(I), I, zeros(size(I));
image(R)
0 Kommentare
Siehe auch
Kategorien
Mehr zu Green finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!