How to plot imagesc plot over .jpg image?
4 views (last 30 days)
Show older comments
Kalasagarreddi Kottakota
on 4 Feb 2022
Commented: Kalasagarreddi Kottakota
on 4 Feb 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
0 Comments
Accepted Answer
DGM
on 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]);
More Answers (0)
See Also
Categories
Find more on Orange in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!