Ask Your Question

Revision history [back]

filter2D Filter out crosses

Hello,

I am a bit new to openCV and have been using it pretty successfully for cleaning up and rotating images before OCR. However I have come across a problem with some documents. If you see the attached image below you will see that if you zoom into the image there are all these little plus looking things in white. I was wondering if someone could point me in the right direction for removing them. I tried something like below. However I believe I am a off in what I am trying to do. If this is in the right direction, could you point me to what would be a better value for my kernel. Or if this is totally off, what kind of method should I be using? Thank you! (note plus sign is 3x3 box)

`cv::Mat myPlusKernel = (cv::Mat_<float>(5, 5) << -0.025, -0.025, -0.025, -0.025, -0.025, -0.025, -0.025, 0.3, -0.025, -0.025, -0.025, 0.3, 0.3, 0.3, -0.025, -0.025, -0.025, 0.3, -0.025, -0.025, -0.025, -0.025, -0.025, -0.025, -0.025);

cv::filter2D(img1_pre, img1, -1, myPlusKernel, cv::Point(-1, -1), (0, 0), cv::BORDER_DEFAULT);
if (debug) {
    cv::namedWindow("CK", cv::WINDOW_AUTOSIZE); // Create a window for display.
    cv::imshow("CK", img1); // Show our image inside it.
    cv::imwrite("CK.jpg", img1);
    cv::waitKey(0);
}`

image description