简体   繁体   中英

change the color of image in matlab

in matlab I change the color of some pixels of an image to black but the color changes to blue. I can't understand the problem.My code is below. could any one help me?

img = imread('test.png');
for i = 1 : 200
  for j = 1: 640
    img(i,j) = 0;
  end 
end

perhaps you have an RGB image, so you have to write:

img(i,j,:) = 0

you should also check the output of the following: class(img) and size(img)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM