Overlaying Compass Plot on an Image

8 次查看(过去 30 天)
Paulo
Paulo 2024-7-30
编辑: Paulo 2024-7-30
I would like to overlay a compass plot on top of an image. I would need to set the specific location where I want the plot, and its size. I tried using "hold on" but it didn't work.

回答(1 个)

Piyush Kumar
Piyush Kumar 2024-7-30
You can use imfuse function. It creates a composite image from two images. There are examples on this page explaining how to create overlay image.
% Generate some data for the compass plot
U = randn(1,50);
V = randn(1,50);
% Create the compass plot and save it as an image
% figure;
% Create a smaller figure for the compass plot
figure('Position', [100, 100, 150, 150]); % Adjust the size as needed
compass(U, V);
saveas(gcf, 'compass_plot.jpg');% Load or import your image
img = imread('<your-image-path>');
% Load the compass plot image
compass_img = imread('compass_plot.jpg');
% Use imfuse to overlay the compass plot image on the original image
overlay_img = imfuse(img, compass_img, 'falsecolor','Scaling','joint','ColorChannels',[1 2 0]);
% Display the overlay image
% figure;
imshow(overlay_img);
You can adjust the position of the compass plot in the figure function.

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by