Azzera filtri
Azzera filtri

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..

1 visualizzazione (ultimi 30 giorni)
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)

Risposta accettata

Kevin Holly
Kevin Holly il 18 Apr 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,'.')

Più risposte (0)

Categorie

Scopri di più su Images in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by