The invention discloses a gravitational lens critical curve contour tracking method and
system based on nearest neighbor distance and geometric constraint, and relates to the technical field of
image processing. The method comprises the steps that after a contour
point set is obtained, double tolerance is carried out through a nearest neighbor distance method, an initial
base line is determined through two-
step tracking search, and the contour tracking process is accurately controlled by setting a direction tolerance parameter and a distance tolerance parameter. In the
iteration process, combining a direction constraint (an included angle cosine value is greater than a preset threshold value) and a distance constraint (a distance proportion is smaller than the preset threshold value) to screen a next contour point, and performing
nearest neighbor search again when a point conforming to the constraint is not found; meanwhile, a double-contour synchronous tracking method is provided, and the consistency of associated contours is ensured by synchronously exchanging corresponding points. The
system comprises a geometric calculation module, a nearest neighbor searching module, a tolerance tracking module and a critical pair tracking module. The method improves the continuity and accuracy of contour tracking, is especially suitable for high-precision tracking of lens curve and critical-caustics peer-to-peer complex contours and multi-contour associated scenes, and can realize high-resolution and smooth contour extraction. Compared with a traditional method, the method has the remarkable advantages in the aspects of tracking precision, robustness and complex geometrical shape
processing capacity.