Changing the size of a subimage plot in a subplot

2 visualizaciones (últimos 30 días)
tim
tim el 16 de Abr. de 2013
Respondida: Walter Roberson el 2 de Jul. de 2015
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

Respuestas (2)

Bogdan Dzyubak
Bogdan Dzyubak el 2 de Jul. de 2015
Editada: Bogdan Dzyubak el 2 de Jul. de 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 el 2 de Jul. de 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.

Categorías

Más información sobre White en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by