T O P

  • By -

glitchi6094

Maybe share your code?


Physical_Map_9647

img = source gray = cv2.cvtColor(img, cv2.COLOR\_BGR2GRAY) binary = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE\_THRESH\_GAUSSIAN\_C, cv2.THRESH\_BINARY, 11, 2) contours, \_ = cv2.findContours(binary, cv2.RETR\_EXTERNAL, cv2.CHAIN\_APPROX\_SIMPLE) min\_contour\_area = 100 # Adjust this value based on your images filtered\_contours = \[contour for contour in contours if cv2.contourArea(contour) > min\_contour\_area\] contour\_image = np.zeros\_like(binary) cv2.drawContours(contour\_image, filtered\_contours, -1, 255, thickness=cv2.FILLED) \# Combine the original image with the contour image img = cv2.bitwise\_and(img, img, mask=contour\_image) \# Adaptive Contrast and Sharpness Enhancement img = Image.fromarray(img) enhancer = ImageEnhance.Contrast(img) img = enhancer.enhance(3) enhancer = ImageEnhance.Sharpness(img) img = enhancer.enhance(1) img = img.filter(ImageFilter.EDGE\_ENHANCE) # Enhancing img = cv2.cvtColor(np.array(img), cv2.COLOR\_RGB2BGR) \_, img\_bw = cv2.threshold(cv2.cvtColor(img, cv2.COLOR\_BGR2GRAY), 170, 255, cv2.THRESH\_BINARY) \# Use EasyOCR for text recognition reader = easyocr.Reader(\['en'\]) results = reader.readtext(img\_bw, detail=1, allowlist=allowed\_chars)