Image 如何保存分割后的图像

Image 如何保存分割后的图像,image,matlab,Image,Matlab,如何保存分割后的每个图像,下面是我的matlab代码: A = imread('MILD NPDR8.JPG'); %// size(384x512x3) nCol = 2; %// number of Col blocks nRow = 2; %// number of Row blocks m = size(A,1)/nRow; %// Sub-matrix ro

如何保存分割后的每个图像,下面是我的matlab代码:

A = imread('MILD NPDR8.JPG');       %// size(384x512x3)
nCol = 2;                        %// number of Col blocks
nRow = 2;                        %// number of Row blocks
m = size(A,1)/nRow;              %// Sub-matrix row size (Should be an   integer)
n = size(A,2)/nCol;              %// Sub-matrix column size (Should be an integer)

imshow(A);                       %// show original image

out1 = reshape(permute(A,[2 1 4 3]),size(A,2),m,[],size(A,3));
out2 = permute(reshape(permute(out1,[2 1 3 4]),m,n,[],size(A,3)),[1 2 4 3]);

figure;
for i = 1:nCol*nRow
subplot(nRow,nCol,i); imshow(out2(:,:,:,i));
end
这是我的结果:
在for循环中使用MATLAB的imwrite函数。 第一个变量应该是输出图像,第二个变量是图像名称。 使用num2str为每个图像生成唯一的文件名:

for i = 1:nCol*nRow
    subplot(nRow,nCol,i); imshow(out2(:,:,:,i));
    imwrite(out2(:,:,:,i),[num2str(i) '.jpg']);
end

你试过保存吗?我已经在尝试imsave,但同样也无法保存每个图像…如何保存包含所有图像的图形?