[英]How to extract text from these colored images?
I want to extract the text on Labels from the images. 我想从图像中提取标签上的文本。 The images are coloured and are in a real-life environment.
图像是彩色的,并且处于现实生活中。 PFA images.
PFA图像。 Sample Image
示例图像
I have tried multiple solutions: 我尝试了多种解决方案:
image = cv2.imread("p18-73.png",0)
thresh = cv2.adaptiveThreshold(image,255, cv2.ADAPTIVE_THRESH_GAUSSIAN_C, cv2.THRESH_BINARY, 11,2)
coords = np.column_stack(np.where(thresh > 0))
angle = cv2.minAreaRect(coords)[-1]
The above pre-processing code is not working. 上述预处理代码无效。 Can you please tell me what is the best way to approach this image?
你能否告诉我接近这张图片的最佳方法是什么?
Did you check the result of cv2.adaptiveThreshold()? 你检查了cv2.adaptiveThreshold()的结果吗? The result of cv2.adaptiveThreshold() is like this:
cv2.adaptiveThreshold()的结果如下:
I think this is not what you want. 我想这不是你想要的。 Try to use global threshold cv2.threshold(), and adjust the threshold value.
尝试使用全局阈值cv2.threshold(),并调整阈值。
ret, thresh = cv2.threshold(image, 240, 255, cv2.THRESH_BINARY)
Also, you can add cv2.morphologyEx() to remove the noise. 此外,您可以添加cv2.morphologyEx()来消除噪音。
kernel = np.ones((2,2),np.uint8)
thresh = cv2.morphologyEx(thresh, cv2.MORPH_OPEN, kernel)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.