user1549846
user1549846

Reputation: 1

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

Upvotes: 0

Views: 4753

Answers (1)

Amro
Amro

Reputation: 124563

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)

Upvotes: 1

Related Questions