The meaning of code on this program
    3 views (last 30 days)
  
       Show older comments
    
Hi.
That is a code which produce a difference picture on Matlab.
That is my professor code, but i cannot fully understand.
The knowledge point is image on Matlab.
% read an image: imread()
% show an image: imshow()
% eg.
clear, close all
I = imread('pout.tif'); % read
for i = 1:size(I,1) 
    for j = 1:size(I,2)
        if (rem(i,2)==0 && rem(j,2)==0)
            I(i,j) = 0;
        end
    end
end
% show a image
imshow(I); 
What is the meaning of i = 1:size(I,1) and what is the purpose of rem(i,2) == 0 && rem(j,2) == 0;
Thank you all.
0 Comments
Accepted Answer
  KSSV
      
      
 on 26 Mar 2022
        clear, close all
I = imread('pout.tif'); % this is to read the image pout.tif 
for i = 1:size(I,1)   % this is loop from 1 to number of rows of the image (REad abou the fnction size)
    for j = 1:size(I,2) % this is loop from 1 to number of columns of the image. So basically the loops cover each pixel of the image i.e. each and every element of matrix
        if (rem(i,2)==0 && rem(j,2)==0)  % if the row, collumn is even 
            I(i,j) = 0; % repalce the pixel by 0 
        end
    end
end
You can try yourself everything instead of asking a question. Read the documentation of rem. 
0 Comments
More Answers (0)
See Also
Categories
				Find more on Image Processing Toolbox in Help Center and File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
