Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do u know how can i keep only the page number ? #1

Open
konos93 opened this issue Dec 20, 2023 · 0 comments
Open

do u know how can i keep only the page number ? #1

konos93 opened this issue Dec 20, 2023 · 0 comments

Comments

@konos93
Copy link

konos93 commented Dec 20, 2023

i used this

import sys
import cv2
from matplotlib import pyplot as plt

def GetBoundingRectangles(IMG_PATH, output_path):
img = cv2.imread(IMG_PATH)
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
gray2 = gray.copy()
ret, thresh = cv2.threshold(gray, 127, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU)
contours, hier = cv2.findContours(thresh, cv2.RETR_LIST, cv2.CHAIN_APPROX_SIMPLE)

secs = []
for cnt in contours:
    if 550 < cv2.contourArea(cnt) < 1050:
        (x, y, w, h) = cv2.boundingRect(cnt)
        cv2.rectangle(gray2, (x, y), (x+w, y+h), 0)
        secs.append(gray2[y:y+h, x:x+w])


cv2.imwrite(output_path, gray2)

image_path = 'a.jpg'
output_path = 'processed_image.jpg'
GetBoundingRectangles(image_path, output_path)

on that

a

the result is like that

processed_image

do u know how can i keep only the page number area ?
the page number usually is top left , top right , bottom left , bottom right or in the middle down

do u know how can i white everything outside the black boxes inside the image and keep anything inside

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant