Changing the size of a subimage plot in a subplot

1 vue (au cours des 30 derniers jours)
tim
tim le 16 Avr 2013
I need to display two images in one figure. They need to be in one figure, because I need to make a movie of a series of 1000s of these images.
The two images have different colormaps. Therefore, the only way (I could find) to display them is to use subimage() from the image processing toolbox.
Actually this worked OK, but now I cannot scale the image any more. Example Code is below: The same clown that is displayed with subimage does not come out scaled to the full width of the plot.
Can anybody tell me how to display two images with different colormaps and still be able to change their size?
Any help is appreciated.
Thanks
Philipp
if true
s = load('clown') ;
ah1 = subplot(2,1,1);
image(s.X);
cb = colorbar('location','NorthOutside');
ah2 = subplot(2,1,2);
subimage(s.X , gray);
pos1 = get(ah1,'Position');
pos2 = get(ah2,'Position');
pos1(3) = .9 ;
pos2(3) = .9 ;
set(ah1,'Position',pos1);
set(ah2,'Position',pos2);
end

Réponses (2)

Bogdan Dzyubak
Bogdan Dzyubak le 2 Juil 2015
Modifié(e) : Bogdan Dzyubak le 2 Juil 2015
One way to do this is by displaying an image with the colormap, capturing it with getframe, and then displaying the result in the subimage:
imshow(X); colormap('jet');
f = getframe(gca); % current axis
figure;
subplot(...); subimage(f.cdata) % jet colormap
subplot(...); subimage(Y); % grayscale

Walter Roberson
Walter Roberson le 2 Juil 2015
Starting in R2014b, each axes can have a different colormap.
Before that, you can use the File Exchange contribution "freezeColors" to convert the images to truecolor.
You can put two images at different positions in the same axes by using image() or imagesc() with the XData and YData parameters.

Catégories

En savoir plus sur Blue dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by