How to plot imagesc plot over .jpg image?

4 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

DGM
DGM il 4 Feb 2022
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]);

Più risposte (0)

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by