How display different blocks of the images in one figure?

2 次查看(过去 30 天)
I have divided image into blocks. How to display it using one figure only?
  3 个评论
DGM
DGM 2021-8-30
编辑:DGM 2021-8-30
Assemble the blocks back into one image by concatenation or indexing. If the central block contains no unique data, then it's redundant. Unless you provide a concrete example of what you did, you'll have to figure out the indexing yourself. Not all image geometries are integer-divisible by 2 or 4, so whatever rounding you did during detiling will need to be taken into account.

请先登录,再进行评论。

回答(2 个)

Image Analyst
Image Analyst 2021-8-30
First crop out the portions of the image you want then use subplot():
suplot(3, 3, 1);
imshow(upperLeftImage);
suplot(3, 3, 3);
imshow(upperRightImage);
suplot(3, 3, 5);
imshow(middleImage);
suplot(3, 3, 7);
imshow(lowerLeftImage);
suplot(3, 3, 9);
imshow(lowerRightImage);
Is that what you want?
  2 个评论
anu
anu 2021-8-30
Actually central image should display as shown in attached image.
Image Analyst
Image Analyst 2021-8-30
You are showing the quadrants of the image stitched together. Thus that just gives the original image. So you can just simply do
imshow(yourOriginalImage);
If you want lines half way across you can do this:
yourOriginalImage = imread('peppers.png');
imshow(yourOriginalImage);
axis('on', 'image');
[rows, columns, numberOfColorChannels] = size(yourOriginalImage)
xline(columns/2, 'Color', 'y', 'LineWidth', 3);
yline(rows/2, 'Color', 'y', 'LineWidth', 3);
pos = [columns/2 - columns/4, rows/2 - rows/4, columns/2, rows/2];
rectangle('Position', pos, 'EdgeColor', 'y', 'LineWidth', 3, 'LineStyle', '--');
If that's not what you want, then show what you want with an actual image. Mock something up in Photoshop if you have to.

请先登录,再进行评论。


DGM
DGM 2021-8-30
If you want them tiled as shown, then you're going to have to reassemble them into one image.
A = imread('cameraman.tif');
% geometry needs to be integer-divisible by 4
bksz = floor([size(A,1) size(A,2)]/4)
% split image
nw = A(1:2*bksz(1),1:2*bksz(2));
ne = A(1:2*bksz(1),2*bksz(2)+1:4*bksz(2));
sw = A(2*bksz(1)+1:4*bksz(1),1:2*bksz(2));
se = A(2*bksz(1)+1:4*bksz(1),2*bksz(2)+1:4*bksz(2));
md = A(bksz(1)+1:3*bksz(1),bksz(2)+1:3*bksz(2));
% reassemble image
B = [nw ne; sw se];
% if center block is nonunique, it's not needed
% if it is unique, then insert it
B(bksz(1)+1:3*bksz(1),bksz(2)+1:3*bksz(2)) = md;
immse(A,B)
imshow(B)
What I said about being integer-divisible by 4 still applies. If the source image geometry is not integer-divisible by 4, then reconstruction has to take into account how you detiled the image. The above code simply discards excess edge vectors. In the case of an improperly-sized source image, B will be smaller than A, though their NW corners will be aligned.

类别

Help CenterFile Exchange 中查找有关 Computer Vision with Simulink 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by