[英]How to change a part of the color of the background, which is black, to white?
I have been working on PyTesseract OCR and converting PDF to JPEG inorder to OCR the image. 我一直在研究PyTesseract OCR,并将PDF转换为JPEG,以便对图像进行OCR。 A part of the image has a black background and white text, which Tesseract is unable to identify, whereas all other parts of my image are being read perfectly well.
图像的一部分具有黑色背景和白色文本,Tesseract无法识别该文本,而我图像的所有其他部分都被很好地读取。 Is there a way to change a part of the image that has black background?
有没有办法改变具有黑色背景的图像的一部分? I tried a few SO resources, but doesn't seem to help.
我尝试了一些SO资源,但似乎无济于事。 I am using Python 3, Open CV version 4 and PyTesseract
我正在使用Python 3,Open CV版本4和PyTesseract
opencv has a bitwise not function wich correctly reverses the image opencv具有按位不起作用,可以正确反转图像
you can put a mask / freeze on the rest of the image (the part that is correct already) and use something like this: 您可以在图像的其余部分(已经正确的部分)上放置遮罩/冻结,并使用以下方法:
imageWithMask = cv2.bitwise_not(imageWithMask) imageWithMask = cv2.bitwise_not(imageWithMask)
alternatively you can also perform the operation on a copy of the image and only copy over parts / pixels / regions you need.... 或者,您也可以对图像的副本执行操作,并且仅复制所需的部分/像素/区域。...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.