points on a contour and meshgrid

2 ビュー (過去 30 日間)
ttopal
ttopal 2017 年 3 月 7 日
回答済み: KSSV 2017 年 3 月 8 日
Hi,
I have a set of points on a contour, and a meshgrid of points. I need to use all the points in this meshgrid except when it falls on the contour. Is there a way other than comparing each point?
here is the code and the result graph;
I = imread('circle.png');
format long;
% figure(1)
% imshow(I)
IM = im2bw(I);
IM2 = imcomplement(IM);
[r, c] = find(IM2, 1, 'first');
mycontour = bwtraceboundary(IM2, [r c] ,'E',8,Inf,'clockwise') ; % returns x,y points
[a,~]=size(mycontour);
mycontour2 = [mycontour(1:30:a,1),mycontour(1:30:a,2)];
%this line is to adjust the points to reasonable scale in excel.
mycontour3 = [(mycontour2(:,2)-800)/1000,(mycontour2(:,1)-640)/1000];
xlswrite('known_point_set.xlsx',mycontour3);
% figure(3)
% imshow(I)
hold on;
plot(mycontour3(:,2),mycontour3(:,1),'*r','LineWidth',1); %(plot y vs x)
[X,Y] = meshgrid(-1:.1:1);
hold on;
plot(X,Y,'.k');

採用された回答

KSSV
KSSV 2017 年 3 月 8 日
How about doing interpolation with the contour points and mesh grid points with no extrapolation. If the meshgrid point lies on the contour, it will result into some value, if not a NaN; this helps in finding out whether point lies on contour or not.

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by