vectorize operation on image processing

조회 수: 11 (최근 30일)
thanos patrikas
thanos patrikas 2019년 2월 17일
답변: thanos patrikas 2019년 2월 20일
Hi! I want to vectorize the variable final on this code :
for i = 1:sz1
for j = 1:sz2
if (bw(i,j)==1)
final(i,j,1)=255;
final(i,j,2)=0;
final(i,j,3)=0;
else
final(i,j,1)=I(i,j,1);
final(i,j,2)=I(i,j,2);
final(i,j,3)=I(i,j,3);
end
end
end
bw : black and white array
I : the original image
final : the array i want to store the values
I want to vectorize it because i want to speed up my code.
Can enyone help?
thnks

채택된 답변

thanos patrikas
thanos patrikas 2019년 2월 20일
solved it!
final=I;
final(bw==1)=255;

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by