MATLAB: Use a for loop to make half the image black and white

for loophurryimpixelinfophoto problem

My professor wants us to use a for loop to make half an image black and white going pixel by pixel. I'm assuming you would use impixelinfo within the for loop with conditions but nothing I'm doing is working and I'm getting a ton of random errors.

Best Answer

All I had to do was this
a = imread('Clooney.jpg');
[M N ~]=size(a);
gray1=rgb2gray(a);
for i = 1:3
a(1:M,1:N/2,i)=gray1(1:M,1:N/2);
end
imshow(a)