How can i use parfor in my code?

I get an error saying "The variable rgb in a parfor cannot be classified." when i use "parfor" instead of for
here is my code
for m=1:size(rgb,1)
for n= 1:size(rgb,2)
for mm=1:size(t1rgb,1)
for nn= 1:size(t1rgb,2)
if abs(rgb(m,n,1)-t1rgb(mm,nn,1))<2 & abs(rgb(m,n,2)-t1rgb(mm,nn,2))<2 & abs(rgb(m,n,3)-t1rgb(mm,nn,3))<2
gray = .3*rgb(m,n,1)+.59*rgb(m,n,2)+.11*rgb(m,n,3);
rgb(m,n,:)= [gray gray gray];
end
end
end
end
end

댓글 수: 1

Walter Roberson
Walter Roberson 2018년 3월 2일
I really recommend that you vectorize your code.
Do I understand correctly that for each given pixel location, if the pixel is within (+/-2, +/-2, +/-2) for any pixel in t1rgb, that you want to replace the rgb pixel with a gray scale version of itself ?? If so then you could vectorize the test by using ismembertol() with an absolute tolerance configured.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

질문:

2018년 3월 2일

댓글:

2018년 3월 2일

Community Treasure Hunt

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

Start Hunting!

Translated by