필터 지우기
필터 지우기

How can we pass gpuArray in Cdata of imshow?

조회 수: 3 (최근 30일)
JAI PRAKASH
JAI PRAKASH 2018년 7월 11일
댓글: Tomycj 2022년 10월 29일
finalImage = imshow(gpuArray(imread(imName))); % this is OK
BUT
set(finalImage,'CData',gpuArray(imread(imName))) ; % Is showing error
Error using matlab.graphics.primitive.Image/set
Error setting property 'CData' of class 'Image':
Value must be either:
Truecolor - a 4xN array of type numeric or logical type
Colormapped - an MxN vector of numeric or logical type
I am using this set CData in a while loop to save time.

채택된 답변

Rik
Rik 2018년 7월 11일
Because image is not holding your hand (and imshow is), you need to do the work yourself. In this case that means you need to get the data from the gpuArray back out to a normal array with the gather function. I'm not sure if this will get you any speed increase compared to skipping the call to gpuArray in the first place.
  댓글 수: 1
Tomycj
Tomycj 2022년 10월 29일
So while creating and image object, the input array is automatically gathered, but not when you want to manually change its value? Is that what is happening here below?
M1 = gpuArray([1 2 3])
im=image('CData', M1,'CDataMapping','direct'); % This works
im.CData = M1 % This doesn't
im.Cdata = gather(M1) % This works, but is VERY slow

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by