How to plot imagesc plot over .jpg image?

4 visualizaciones (últimos 30 días)
Kalasagarreddi Kottakota
Kalasagarreddi Kottakota el 4 de Feb. de 2022
Comentada: Kalasagarreddi Kottakota el 4 de Feb. de 2022
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

Respuesta aceptada

DGM
DGM el 4 de Feb. de 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]);

Más respuestas (0)

Categorías

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

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by