Errors in Contour detection
Hi
I am doing some simple contour detection, thresholding the images then using findcontours(). To test it, I've created a simple image in paint, manually colouring in 4 pixels hence having a known area and other more complex examples. When I run this through, everything seems offset slightly, in the case of a 2x2 square, this comes out to have an area of 1. Clearly I'm missing something. Any suggestions? Example below(to scale). I feed in the image on the left, 3x3 pixels wide. Looking at the coordinates after findcontours(), the result is only 2x2 pixels wide. I can see this in the raw polygons as well as the bitmap output.
Example attached
private void GeneratePolygon()
{
Mat img = Cv2.ImRead(RawImagePath, ImreadModes.GrayScale);
Cv2.Threshold(img, img, Threshold, 255, ThresholdTypes.Binary);
CvPoint[][] Contours;
HierarchyIndex[] hierarchyIndexes;
Cv2.FindContours(img, out Contours, out hierarchyIndexes, RetrievalModes.List, ContourApproximationModes.ApproxNone);
Suggestions : add an image in your post