필터 지우기
필터 지우기

Matlab code without for loop

조회 수: 1 (최근 30일)
Jab
Jab 2016년 1월 12일
편집: jgg 2016년 1월 12일
Image contains 4 pixels . 0-background, 1,2 and 3 freground pixels.Can anyone help me how to improve the following code for computational efficiency? Thanks
[m n]=size(image);
for p=1:m
for q=1:n
if image(p,q)==1
image(p,q)=255;
else
image(p,q)=0;
end
end
end

채택된 답변

jgg
jgg 2016년 1월 12일
편집: jgg 2016년 1월 12일
I think this should work:
i = image('file.jpg')%load in whatever image it is
i(i == 1) = 255;
i(i ~= 255) = 0;

추가 답변 (0개)

카테고리

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

제품

Community Treasure Hunt

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

Start Hunting!

Translated by