In this program, I need to select the point on the contour image that has the same abscissa as the center of the contour and has the highest ordinate. However, since the contour is not full closed, the last line does not return any thing. How can I fix this problem.
edge = MorphologicalPerimeter[ColorNegate@img] // DeleteSmallComponents
coordinatescontour = PixelValuePositions[edge, 1] ;
center = Round[ComponentMeasurements[edge, "BoundingDiskCenter"][[1, 2]]];
radius = Round[ComponentMeasurements[edge, "BoundingDiskRadius"][[1, 2]]];
Show[edge,Graphics[{{Red, Circle[center, radius]}, {Green, Point[center]}}]]
(*I need to select the point on the contour which has the same abscissa as the center point and has the highest ordinate *)
Sort[Select[coordinatescontour, #[[1]] == center[[1]]&]][[1]]
coordinatescontour = [...] // DeleteSmallComponents
theDeleteSmallComponents
is probably a mistake. Other than that, your code seems to do what you want already. $\endgroup$