简体   繁体   English

如何将背景颜色的一部分(黑色)更改为白色?

[英]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.

相关问题 如何使用 python 将文本布局颜色更改为白色并将文本更改为黑色? - how to change the text layout color to white and text to black using python? 如何计算二进制图像中斑点的实例(白色斑点和黑色作为背景色) - How to count instances of a blob in a binary image, (white blobs and black as background color) 在python中将图像黑色背景转换为白色,将白色转换为黑色 - convert images black background to white and white to black in python 如何在回收视图中更改所选项目的背景颜色。 我也想要它 select 自动成为第一项(白色背景) - How can I change background color of selected item in recycleview. also I want it to select automatically the 1st item(with white background) 当同时存在白色和黑色背景时,如何将整个图像的背景转换为白色? - How to convert the background of the entire image to white when both white and black backgrounds are present? Pygame:如何更改背景颜色? - Pygame: How to change background color? 如何更改 Treeview 的背景颜色 - How to change the background color of a Treeview 如何去除这种黑色图像的背景? - How do i remove the background of this type of images with black color? 如何从图像中检测矩形块并将其更改为白色? - How to detect a rectangle block from an image and change it to white color? 如何使用 tkinter 更改我的背景颜色? - How to change my background color with tkinter?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM