Effacer les filtres
Effacer les filtres

Hello, I am trying to get the X and Y values from a Plot. This plot is generated from a loop, and the plot represents the boundary of an image..

2 vues (au cours des 30 derniers jours)
close all
clear all
% The image I am trying to read
A = imread('Britain.png');
% The boundaries around the image
BW = im2bw(A);
[B,L] = bwboundaries(BW);
% To put the x and y values
double x1=[];
double y1=[];
%imshow(label2rgb(L, @jet, [.5 .5 .5]))
hold on
% A loop to plot only the boundaries, because I only want the boundary and not the image
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'r', 'LineWidth', 1)
j=findobj(gca,'Type','line')
x1(k)=j(k).XData(k)
y1(k)=j(k).YData(k)
end
%plot(x1,y1)

Réponse acceptée

Kevin Holly
Kevin Holly le 18 Avr 2023
% The image I am trying to read
A = imread('Britain.png');
% The boundaries around the image
BW = im2bw(A);
[B,L] = bwboundaries(BW);
% To put the x and y values
double x1=[];
double y1=[];
%imshow(label2rgb(L, @jet, [.5 .5 .5]))
hold on
x=[];
y=[];
% A loop to plot only the boundaries, because I only want the boundary and not the image
for k = 1:length(B)
boundary = B{k};
plot(boundary(:,2), boundary(:,1), 'r', 'LineWidth', 1)
% j=findobj(gca,'Type','line');
% x1(k)=j(k).XData(k) ;
% y1(k)=j(k).YData(k);
x = [x; boundary(:,2)];
y = [y; boundary(:,1)];
end
figure
plot(x,y)
figure
scatter(x,y,'.')

Plus de réponses (0)

Catégories

En savoir plus sur Images dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by