Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Oh, duh.

Look at your pixels. You're repeating some of them. Here's a corrected list.

        if (thisPixel >= gray.at<uchar>(i - 1, j - 1))
            thisCode |= (1 << 7);
        if (thisPixel >= gray.at<uchar>(i, j - 1))
            thisCode |= (1 << 6);
        if (thisPixel >= gray.at<uchar>(i + 1, j - 1))
            thisCode |= (1 << 5);
        if (thisPixel >= gray.at<uchar>(i-1, j))
            thisCode |= (1 << 4);
        if (thisPixel >= gray.at<uchar>(i + 1, j))
            thisCode |= (1 << 3);
        if (thisPixel >= gray.at<uchar>(i - 1, j + 1))
            thisCode |= (1 << 2);
        if (thisPixel >= gray.at<uchar>(i, j + 1))
            thisCode |= (1 << 1);
        if (thisPixel >= gray.at<uchar>(i + 1, j + 1))
            thisCode += 1;