How to find image boundary is above or below the given line,

3 vues (au cours des 30 derniers jours)
cha bha
cha bha le 22 Mai 2018
Commenté : cha bha le 24 Mai 2018
grayImage = imread('w.png');
I = im2bw(grayImage);
[y,x] = find(~I) ;
idx = boundary(x,y) ;
% GEt boundary of the human
% Boundary points
x = x(idx) ; y = y(idx) ;
%
imshow(I) ;
hold on
plot(x,y,'b') ;
% [xx,yy] = getpts() ; % this forms straight line desired
uiwait(msgbox('Locate the top of the ear?'));
[x2,y2] = ginput(1);
loacationEar=plot(x2,y2,'r+', 'MarkerSize', 10);
uiwait(msgbox('Locate the point in starting point of your spine?'));
[x1,y1] = ginput(1);
loacationSpine=plot(x1,y1,'r+', 'MarkerSize', 10);
xx = [x2 y2] ;
yy = [x1 y1] ;
plot([x2 x1], [y2 y1],'r')
end
Using this code i able to do get below result
  2 commentaires
jonas
jonas le 22 Mai 2018
What exactly is the question?
cha bha
cha bha le 22 Mai 2018
How can i know whether red line is below the blue line or above the blue line ?

Connectez-vous pour commenter.

Réponse acceptée

Ameer Hamza
Ameer Hamza le 22 Mai 2018
You can use inpolygon() to find you if the points on the red line are inside the blue polygon. Since the blue polygon is non-convex, you need to take several points on the red line to check whether all the points lie inside the blue polygon. If the condition is true, and the red line is completely inside the polygon then you can conclude that it is below the blue line. Add the following lines at the end of your code
X1 = [x1 y1];
X2 = [x2 y2];
t = linspace(0,1,100); % how many points to take on the red straight line
pts = (X1.*(1-t)' + X2.*t')
isInside = all(inpolygon(pts(:,1), pts(:,2), x, y))
If I draw the points like this
the code will return
isInside =
logical
1
Similarly, if you draw a line outside the blue polygon, isInside will be false.
  3 commentaires
Ameer Hamza
Ameer Hamza le 23 Mai 2018
Have you checked whether the on vector have any 1s in it?
cha bha
cha bha le 24 Mai 2018
now its working,thank you.

Connectez-vous pour commenter.

Plus de réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by