How to plot imagesc plot over .jpg image?
4 次查看(过去 30 天)
显示 更早的评论
The result of this plot only shows image 'Top.jpg' with a colorbar, but I am looking for imagesc plot over the rgb image.
figure()
rgb = imread('Top.jpg');
image(rgb)
axis image
hold on
imagesc(x_coord,y_coord,Ax)
alpha(0.5)
colorbar
colormap jet
0 个评论
采纳的回答
DGM
2022-2-4
Both objects exist in the same axes, so they share the same coordinate space. If you're going to specify x,y coordinates for the second object, then it's in units of pixels. If you set x_coord and y_coord to be something like [0 1], then the second plot will be microscopic and essentially invisible.
rgb = imread('peppers.png');
s = size(rgb);
image(rgb)
axis image
hold on
% note the scale
h2 = imagesc([0 100],[0 100],rand(100));
h2.AlphaData = 0.5;
colorbar
colormap jet
How you handle this depends entirely on the meaning of those coordinates with respect to the other image. If your x,y coordinates are mismatched like in the above example and you want them to cover the image, then use them for both images.
figure
rgb = imread('peppers.png');
s = size(rgb);
h1 = image([0 100],[0 100],rgb);
hold on
h2 = imagesc([0 100],[0 100],rand(100));
h2.AlphaData = 0.5;
colorbar
colormap jet
% force unequal aspect ratio
set(gca,'dataaspectratio',[s(1:2)/max(s(1:2)) 1]);
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Orange 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!