How display different blocks of the images in one figure?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have divided image into blocks. How to display it using one figure only?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/724854/image.png)
3 commentaires
DGM
le 30 Août 2021
Modifié(e) : DGM
le 30 Août 2021
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.
Réponses (2)
Image Analyst
le 30 Août 2021
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 commentaires
Image Analyst
le 30 Août 2021
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', '--');
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/724864/image.png)
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
le 30 Août 2021
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.
0 commentaires
Voir également
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!