The meaning of code on this program

조회 수: 3 (최근 30일)
Shuoze Xu
Shuoze Xu 2022년 3월 26일
답변: KSSV 2022년 3월 26일
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.

채택된 답변

KSSV
KSSV 2022년 3월 26일
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개)

카테고리

Help CenterFile Exchange에서 Image Processing Toolbox에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by