Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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?

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?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.

Example attached

image description

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.wide. I can see this in the raw polygons as well as the bitmap output.

Example attached

image description

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

image description

    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);