plot and figure windows

1 次查看(过去 30 天)
Suleyman Suleymanov
回答: Ayush 2024-10-21
How can use plot function to indicate specific points in the figure window which displays an image?

回答(1 个)

Ayush
Ayush 2024-10-21
Hi,
To indicate specific points in the figure window which display an image, you can first use “hold on” which will allow you to overlay plots on the current figure without erasing the image. Then define the coordinates of the points you want to indicate on the figure and pass them to the “plot” function. Finally, use “hold off” to release the “hold on” the current figure. Refer to an example code below for better understanding:
% Read the image
img = imread('your_image.jpg');
% Display the image
imshow(img);
hold on; % Hold the current figure
% Define the points you want to plot
x = [50, 100, 150]; % X-coordinates of the points
y = [75, 125, 175]; % Y-coordinates of the points
% Plot the points on the image
plot(x, y, 'r*', 'MarkerSize', 10, 'LineWidth', 2);
% Release the hold on the current figure
hold off;

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by