How to VECTORIZE this code and then convert it into a GPU code ?

During vectorization matlab giving me error for this if condition which contains SHORT CIRCUITED OR conditions :- if I(m,n,2)<120||I(m,n,1)>155||I(m,n,3)>160

 채택된 답변

James Tursa
James Tursa 2017년 4월 12일
Try this:
x = I(:,:,2)<120 | I(:,:,1)>155 | I(:,:,3)>160;
gsc = 0.2989*I(:,:,1) + 0.5870*I(:,:,2) + 0.1140*I(:,:,3);
I([x,x,x]) = [gsc(x),gsc(x),gsc(x)];

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 GPU Computing에 대해 자세히 알아보기

제품

질문:

2017년 4월 12일

댓글:

2017년 4월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by