我想将图像分为三个部分,这是我尝试过的:
[filename pathname]=uigetfile('*.png','Pick the image file');
file=strcat(pathname,filename);
I=imread(file);
figure,imshow(I);
title('Input Image');
im1=I;
su=median(im1);
median=ceil(su);
[row, col]=size(I);
%mr = median(row/2); % median of rows
mc = median(col/3); % median of columns
right = I(1:mr , (mc+1):col);
figure,imshow(right)
我希望这可以将图像分为三部分,但可以分为右上和左上并创建镜像
这是我需要分为三部分的图片,但应该是单张图片:
答案 0 :(得分:0)
您可以使用mat2cell
将图像拆分为所需的任意数量:
img = imread('https://i.stack.imgur.com/s4wAt.png');
[h w c] = size(img);
numSplits = 3; % how many splits you want
sw = floor(w/numSplits); % width of split
widths = repmat(sw, 1, numSplits-1);
widths(numSplits) = w - sum(widths); % last one is bit wider if width does not divide
splits = mat2cell(img, h, widths, c); % this splits the image
% show the splits
for ii=1:numSplits
subplot(1,numSplits,ii);
imshow(splits{ii});
end