S=imread(img2.gif);
for img=1:100;
C = mat2cell(S,[10 10],[10 10]);
plot(C);
end
答案 0 :(得分:0)
以下代码将图像分成指定大小的子图像。
im = imread('peppers.png');
widthSub = 10;
heightSub = 10;
numHeightFull = floor(size(im,1)/heightSub);
numWidthFull = floor(size(im,2)/widthSub);
if mod(size(im,1),heightSub) == 0
heights = heightSub*ones(1,numHeightFull);
else
heights = [heightSub*ones(1,numHeightFull),mod(size(im,1),heightSub)];
end
if mod(size(im,2),widthSub) == 0
widths = widthSub*ones(1,numWidthFull);
else
widths = [widthSub*ones(1,numWidthFull),mod(size(im,2),widthSub)];
end
if ndims(im) < 2
subImages = mat2cell(im,heights,widths);
elseif ndims(im) > 2
subImages = mat2cell(im,heights,widths,size(im,3));
end