フィルターのクリア

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 回表示 (過去 30 日間)
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)

採用された回答

Kevin Holly
Kevin Holly 2023 年 4 月 18 日
% 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,'.')

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeImages についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by