Hello I have this code until now but can't remove the grid so I can keep only the characters on the captcha. The function applyfilters dilutes and erodes. I am out of ideas how to solve this problem. I am reading books about image processing but still I am out of ideas...captcha example
cv::Mat imgTrainingNumbers; // imazhi hyrje
cv::Mat imgGrayscale; //
cv::Mat imgBlurred; // transformime te imazhit
cv::Mat imgThresh; //
cv::Mat imgThreshCopy; //
std::vector<std::vector<cv::Point> > ptContours; // vektori me konturet
std::vector<cv::Vec4i> v4iHierarchy; // hierarkia e kontureve
cv::Mat matClassificationInts; // trajnimi i klasifikimeve, duhen bere disa konvertime para se te shkruajme ne skedar
//imazhet e trajnimit, deklarohet si imazh tek dhe me pas shtojme tek ky imazh si te ishte nje vektor. Ne fund duhen ber konvertime para se te shkruhet ne skedar
cv::Mat matTrainingImagesAsFlattenedFloats;
//per te treguar konceptin, po lexoj dhe parashikoj vetem numrat me shkrim dore. Njesoj veprohet edhe per shkronjat
std::vector<int> intValidChars = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
imgTrainingNumbers = cv::imread("data/19-09-16_091821.png"); // lexoj imazhin me bashkesine e trajnimit
if (imgTrainingNumbers.empty()) {
std::cout << "error: Imazhi i trajnimit nuk u lexua\n\n";
return(0);
}
cv::cvtColor(imgTrainingNumbers, imgGrayscale, CV_BGR2GRAY); // kthe ne greyscale
cv::imshow("greyscale", imgGrayscale);
//cv::Mat canny_output;
// Detect edges using canny
//cv::Canny(imgGrayscale, canny_output, 100, 100 * 2, 3);
//cv::imshow("canny output", canny_output);
cv::GaussianBlur(imgGrayscale, // imazh hyrje
imgBlurred, // imazh dajle
cv::Size(5, 5), // zbut gjeresine dhe gjatesine e dritares ne pixel
0); // vlera sigma tregon se sa blur do i vendoset imazhit, 0 e lejon algoritmin zgjedh menyr automatike vleren
// nga grayscale kthejme ne bardhezi (binarizimi i imazhit)
cv::adaptiveThreshold(imgBlurred, // imazh hyrje
imgThresh, // imazh dalje
255, // pixelat qe kalojne limitin i bejme te bardhe te plota (255 rgb)
cv::ADAPTIVE_THRESH_GAUSSIAN_C, // shperndarje gaussiane
cv::THRESH_BINARY_INV, // backgroundi i zi, foregroundi i bardhe
11, // vlera e pixelit fqinj e perdorur te llogaritet vlera thredsholdid
2); // konstante e zbritur nga mesatarja e peshuar
cv::imshow("Binarizimi i imazhit", imgThresh); // shfaq imazhin e binarizuar per reference
Mat afterFilter;
afterFilter = applyFilters(imgThresh);
cv::imshow("After Filters", afterFilter);
//imgThresh = applyFilters(imgThresh);
//cv::imshow("After Filters", imgThresh);