-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathim_split.m
More file actions
22 lines (15 loc) · 709 Bytes
/
im_split.m
File metadata and controls
22 lines (15 loc) · 709 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
function [splitImage] = im_split(image,splitX,splitY)
%% Splits the image into smaller parts for parallel processing
[x, y, z] = size(image);
wholeBlockRows = floor(x / splitX);
wholeBlockCols = floor(y / splitY);
blockVectorX = [wholeBlockRows * ones(1, splitX), rem(x,splitX)];
blockVectorX(blockVectorX==0)=[] ;
blockVectorY = [wholeBlockCols * ones(1, splitY), rem(y,splitY)];
blockVectorY(blockVectorY==0)=[] ;
if z>1
splitImage = mat2cell(image, blockVectorX, blockVectorY, z);
else
splitImage = mat2cell(image, blockVectorX, blockVectorY );
end
end