I have divided one image into subimages--how can I show the subimages lined up near each other?
1 次查看(过去 30 天)
显示 更早的评论
I have divided one image into four smaller images (subimages). How can I show the subimages like the original image, close to each other and with a line or a few pixels between them. I have tried subplot but it didn´t work.
0 个评论
采纳的回答
Thorsten
2013-2-14
编辑:Thorsten
2013-2-14
This implements suggestion #4 of Image Analyst.
I = imread('peppers.png');
I = im2double(I);
Nsubimages = [4 3];
Nsp = 10; % number of separating pixels
sz = size(I);
sznew = [sz(1:2) + (Nsubimages - 1)*Nsp size(I, 3)];
Inew = repmat(1, sznew);
ind1 = round(linspace(1, sz(1), Nsubimages(1) + 1));
ind2 = round(linspace(1, sz(2), Nsubimages(2) + 1));
for i = 1:length(ind1)-1
for j = 1:length(ind2)-1
i1 = ind1(i):ind1(i+1);
i2 = ind2(j):ind2(j+1);
Inew(i1 + (i-1)*Nsp, i2 + (j-1)*Nsp, :) = I(i1, i2, :);
end
end
subplot(1,2,1), imshow(I)
subplot(1,2,2), imshow(Inew)
6 个评论
Pradeep Gowda
2015-8-26
the code for dividing is nice but is there a way to display the contents of cell variable B{} like a single image after finishing our analysis?
更多回答(1 个)
Image Analyst
2013-2-14
You can either
- show the original image (no lines/gaps), or
- save the images to files and use montage() (again, no lines or gaps), or
- you can use a GUI (like use GUIDE) and place 4 axes really close to each other and use imshow() to display the images in the axes, or
- make a larger image and use regular, normal indexing to assign the sub images into the proper location in the larger image.
2 个评论
Image Analyst
2013-2-14
编辑:Image Analyst
2013-2-14
P.S. I decided to give you the benefit of the doubt and assume you've learned not to delete your questions anymore.
Randy Souza
2013-2-14
@Image Analyst: Teemu was not actually deleting questions, but was simply including the entire question in the title and entering ";" as the body.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Processing Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!