I see now the trouble is with the test input, with drawing a circle using cv::circle, which puts it off by one pixel.