MATLAB Answers

How display different blocks of the images in one figure?

1 ビュー (過去 30 日間)
anu 2021 年 8 月 29 日
コメント済み: Image Analyst 2021 年 8 月 30 日
I have divided image into blocks. How to display it using one figure only?
  3 件のコメント
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);
suplot(3, 3, 3);
suplot(3, 3, 5);
suplot(3, 3, 7);
suplot(3, 3, 9);
Is that what you want?
  2 件のコメント
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
If you want lines half way across you can do this:
yourOriginalImage = imread('peppers.png');
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 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;
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.

Community Treasure Hunt

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

Start Hunting!

Translated by