필터 지우기
필터 지우기

How display different blocks of the images in one figure?

조회 수: 2 (최근 30일)
anu
anu 2021년 8월 29일
댓글: Image Analyst 2021년 8월 30일
I have divided image into blocks. How to display it using one figure only?
  댓글 수: 3
anu
anu 2021년 8월 29일
Total 5 blocks. 4 blocks along with central block.
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.

Community Treasure Hunt

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

Start Hunting!

Translated by