The meaning of code on this program
    3 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
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 Kommentare
Akzeptierte Antwort
  KSSV
      
      
 am 26 Mär. 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 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
				Mehr zu Image Processing Toolbox 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!

