vectorize nested loop using imcrop for gpu usage

Hello
I am working with a large dataset (2e+12) and need to clip ~200,000 small matrices (~30*30 pixels) out. I have a functioning nested loop but would like to take advantage of vectorising the code for dual 6 core cpus OR and even taking advantage of the quadro 4000 (8gb ram on card) in my desktop. The large dataset is a DEM cut into several parts and stored in a multidimensional matrix [MD_DEMs]. I thought this would allow gpuArray to be utilized by keeping file size down.
I tried to vectorize a couple of different ways, but can’t seem to get imcrop to play nicely. Any help is appreciated.
S=3; % changeable depending on matrix size and available ram
%fake datasets
MD_DEMs=rand(1000,1000,S); % random matrix
M{1}=[1 546 218 29 29 % made up locations for imcrop
2 128 51 29 29 % [label Xmin Ymin width height]
3 146 58 29 29
4 5 253 29 29
5 45 18 29 29];
M{2}=[6 5 850 29 29
7 546 218 29 29
8 5 12 29 29];
M{3}=[9 5 2 29 29
10 546 218 29 29];
MD_Clips=zeros(30,30,10); % preallocate DEM clips
MD_Lists=zeros(10,1); % preallocate the matrix for row identifier (label)
%code snipet
k=0;
for i=1:S;
[m,~]=size(M{i});
for j=1:m;
k=k+1; % counter so data is not overwritten
MD_Clips(:,:,k)= imcrop(MD_DEMs(:,:,i),M{[i]}(j,2:5));
MD_Lists(k,1)= M{[i]}(j,1);
end
end

回答(0 个)

类别

帮助中心File Exchange 中查找有关 Parallel Computing Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by