gpt4 book ai didi

c++ - 带纹理的图像如何阈值?通过tesseract识别

转载 作者:塔克拉玛干 更新时间:2023-11-03 02:16:52 25 4
gpt4 key购买 nike

源图片:

目标图片:

代码:

cv::Mat sharpenedLena;
cv::Mat kernel = (cv::Mat_<float>(3, 3) << 0, -1, 0, -1, 5, -1, 0, -1, 0);
cv::filter2D(matGrey, sharpenedLena, matGrey.depth(), kernel);
cv::adaptiveThreshold(sharpenedLena, matBinary, 255, cv::ADAPTIVE_THRESH_GAUSSIAN_C, CV_THRESH_BINARY, 55, 30);
cv::Mat dst_img1;
//cv::GaussianBlur(matBinary, dst_img1, cv::Size(3,3), 0, 0);
cv::medianBlur(matBinary, dst_img1, 3);

UIImage *addrUIImage = [ImageUtil UIImageFromCVMat:dst_img1];
[self recognizeImageWithTesseract:addrUIImage withLauange:1];

结果:

三胡南省慈利昙龙三覃河镇文

我觉得应该是图片处理的问题。这里有一个别人的治疗效果。如何实现这种效果?

目标图片:

最佳答案

这是我的结果和代码片段: enter image description here

Mat mSource_Bgr,mSource_Gray,mSource_Hsv,mThreshold;
mSource_Bgr= imread(FileName_S.c_str(),1);

namedWindow("Source Image",WINDOW_AUTOSIZE);
imshow("Source Image",mSource_Bgr);

cvtColor(mSource_Bgr,mSource_Hsv,COLOR_BGR2HSV);

mSource_Hsv = mSource_Hsv + Scalar(0,0,-25); //Subtracting 25 from all the Pixel Values
cvtColor(mSource_Hsv,mSource_Bgr,COLOR_HSV2BGR);// Back to BGR Just for Debug purpose

enter image description here

imshow("Improved Darkness",mSource_Bgr);
imwrite(FileName_S+"_Res.bmp",mSource_Bgr);

cvtColor(mSource_Bgr,mSource_Gray,COLOR_BGR2GRAY); // for Adaptive Thresholding the input Image

adaptiveThreshold(mSource_Gray,mThreshold,255,ADAPTIVE_THRESH_GAUSSIAN_C,THRESH_BINARY,59,10);

enter image description here

imshow("Adaptive Thres",mThreshold);
imwrite(FileName_S+"_Thres.bmp",mThreshold);

您可以通过使用轮廓区域或形态学处理去除噪声,即小点。希望这对您有帮助!

关于c++ - 带纹理的图像如何阈值?通过tesseract识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29817935/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com