Changing the size of a subimage plot in a subplot

1 回表示 (過去 30 日間)
tim
tim 2013 年 4 月 16 日
回答済み: Walter Roberson 2015 年 7 月 2 日
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

回答 (2 件)

Bogdan Dzyubak
Bogdan Dzyubak 2015 年 7 月 2 日
編集済み: Bogdan Dzyubak 2015 年 7 月 2 日
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 2015 年 7 月 2 日
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.

カテゴリ

Help Center および File ExchangeBlue についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by