I want to use chain code for contour correction in an image. The base aim is finding the pairs of critical points and join corresponding pairs of critical points and fill in the polygons formed by all the points in the contour in between the pair of critical points. First of all I obtained the boundary of the binary image by using boundaries in matlab and then I convert this boundary to chain code.Know I should apply a Gaussian smoothing filter to the chain codes and calculate the gradient of the filtered chain codes. the distance between a pair of critical points critical points are subsequently detected using this gradient information. Shall I ask you kindlt to help me doing the remaining works. I try hard but I can't get the correct results.