필터 지우기
필터 지우기

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 CenterFile Exchange에서 Images에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by