How to change from cell to array

조회 수: 3 (최근 30일)
nahyun lee
nahyun lee 2020년 3월 20일
댓글: nahyun lee 2020년 3월 20일
Hi all,
I want this code to run on the GPU.
Maybe O = (num2cell (O, [1 2])) of the RainDetect function; The part is expected to be a problem.
Since this part is a cell, the gpu operation does not seem to work.
I want to change from cell to array, is there a good way?
O = gather(video_ycbcr(gpuArray(video))); % Transfer RGB to YCbCr and retain Y only
O_cpu = {};
O_cpu{1} = O(:,:,001:149);% Can be easily extend to multiple GPU
O_gpu{1} = gpuArray(O_cpu{1});% Move array from CPU to GPU for acceleration
R_gpu{1} = RainDetect(O_gpu{1},paras);
R_cpu{1} = gather(cat(3,R_gpu{1}{:}));
R = R_cpu{1};
%==============================================================================
function [R,iter]=RainDetect(O,paras)
[m,n,t] = size(O);
O = (num2cell(O,[1 2]));
R{1} = gpuArray(zeros(m,n));
B{1} = O{1}-R{1};
iter{1} = 0;
[R{2},B{2},iter{2}]=RainDetect_i(O{2},B{1},paras);
for i = 3:t
disp(i);
[R{i},B{i},iter{i}]=RainDetect_i(O{i},B{i-1},paras);
end

답변 (1개)

KSSV
KSSV 2020년 3월 20일
Read about cell2mat.
  댓글 수: 1
nahyun lee
nahyun lee 2020년 3월 20일
i get this Error: Error using cell2mat (line 7) Cannot support cell arrays containing cell arrays or objects.

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

카테고리

Help CenterFile Exchange에서 GPU Computing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by