Currently, I have a problem finding a good algorithm for obtaining the coordinates of each external boundary point of an object, which, unfortunately, can be complex and contain internal areas.

I have a list of points containing each pixel point of an object already created from the marking algorithm of the connected component. This allowed me to check every coordinate around each pixel in the image, and if it is not there, then I know its space or edge through the following.
public List<IntPoint> SquareSearch(List<IntPoint> ListOfPoints, IntPoint point) { List<IntPoint> UnfoundPixels = new List<IntPoint>(); int MoveX = point.X; int MoveY = point.Y; for (int LTR = MoveX - 1; LTR <= MoveX + 1; LTR++) { for (int TTB = MoveY - 1; TTB <= MoveY + 1; TTB++) { if (ListOfPoints.IndexOf(new IntPoint(LTR, TTB)) == -1) { if ((LTR > -1) && (TTB > -1)) { UnfoundPixels.Add(new IntPoint(LTR, TTB)); } } } } }
However, this process is very slow and proportional to the size of each object, since it must be repeated for each pixel in the object. Any suggestions on an alternative method?
source share