How to add an image to the current axes without replacing existing plots

1 view (last 30 days)
I have created a matrix, called "Final" and I want to plot its contour pattern on an image, in a polygon shape.
I tried "imagesc(Final,"XData",[min_x_2 max_x_2],"YData",[min_y_2 max_y_2],"AlphaData",0.5)" and was able to plot a rectangle contour map successfully. But I want to plot it on a RoI such as [1558,1798; 1790,1806; 1782,2006; 1562,2018].
(Note that the "Final" matrix's contour map might exceed the area of the polygon)
Thank you.

Answers (2)

Matt J
Matt J on 19 Feb 2024
Edited: Matt J on 19 Feb 2024
You can use hold
fcontour(@(x,y) (x-50).^2+(y-50).^2,[20,80],'m'); hold on
imshow(imread('cameraman.tif')); hold off
h=gca; h.Children=flip(h.Children);

Image Analyst
Image Analyst on 19 Feb 2024
See my attached examples to inset images and plots into other images and plots.

Categories

Find more on Contour Plots 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!