plotting multiple images in subplot
71 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi, I have down sampled an image several times and I want to show each image that has been down sampled like in the document attached below. Basically, in subplot I want to plot the original image first, then the first one sampled one and so on. I've tried creating a 2x3 subplot and placing the first one in rows 1:2 and column 4:5, but this approach doesn't give me the subplot I want, even if I create a larger subplot. Any suggestions on how to do this in subplot? Thanks.
1 Commento
Gautam Mohan
il 25 Apr 2016
Hi Jackie,
One way to accomplish this task is to call subplots with the 'position' argument, which allows you to specify exactly on the figure where your axes will be plotted. The coordinates are given as [left, bottom, width, height] where the origin is the top left corner of the figure.
You can read more about this functionality here:
Here is a small code example. In this example, I am downsizing the image by a factor of 2, so each axis I plot must be a quarter of the size of the old one. We start by drawing the original image in the first quadrant of the figure, and then drawing each successive downsampled image in a smaller quadrant:
im = imread('autumn.tif');
im1 = im(1:206,1:206,:); %make the image square for demonstration purposes
im2 = imresize(im1,0.5);
im3 = imresize(im2,0.5);
subplot('position',[1-1 .5 1/2 1/2])
imshow(im1);
subplot('position',[1-.5 .5 1/4 1/4]);
imshow(im2);
subplot('position',[1-.25 .5 1/8 1/8]);
imshow(im3);
Hope this helps!
Risposte (1)
John BG
il 26 Apr 2016
I have modified a zoom basic example:
im = imread('image_zoom_in.jpg'); % image_zoom_iun.jpg is your autumn.tif
im1 = im(1:206,1:206,:);
im2 = imresize(im1,0.5);
im3 = imresize(im2,0.5);
ax1 = subplot(2,2,1);
imshow(im)
ax2 = subplot(2,2,2);
imshow(im1)
%setAllowAxesZoom(h,ax2,false);
ax3 = subplot(2,2,3);
imshow(im2)
%setAxesZoomMotion(h,ax3,'horizontal');
ax4 = subplot(2,2,4);
imshow(im3)
%setAxesZoomMotion(h,ax4,'vertical');

You may want to play with the zoom further.
If you want to really show the images with same zoom, the smaller images with less pixels really showing white around the space where the image has shrunken, then you may have to build another image including all that white space as part of the image.
If you find this answer of any help solving your question,
please click on the thumbs-up vote link,
thanks in advance
John
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!