Pedro Sá Couto
5 years ago
7 changed files with 74 additions and 3 deletions
Binary file not shown.
@ -0,0 +1,33 @@ |
|||
from PIL import Image |
|||
from PIL import ImageOps |
|||
import time |
|||
|
|||
|
|||
i = 1 |
|||
|
|||
while True: |
|||
|
|||
page = Image.open("bounding_box/input%i.jpg"%i) |
|||
|
|||
if i % 2 == 0: |
|||
#check where the for loop is |
|||
print("cropping even") |
|||
|
|||
# left, up, right, bottom |
|||
border = (0, 0, 165, 0) |
|||
finalpage = ImageOps.crop(page, border) |
|||
finalpage.save('cropped/page%i.jpg'%i) |
|||
|
|||
else: |
|||
#check where the for loop is |
|||
print("cropping odd") |
|||
|
|||
# left, up, right, bottom |
|||
border = (165, 0, 0, 0) |
|||
finalpage = ImageOps.crop(page, border) |
|||
finalpage.save('cropped/page%i.jpg'%i) |
|||
|
|||
time.sleep(1) |
|||
print("variable i: ", i) |
|||
|
|||
i+=1 |
@ -0,0 +1,36 @@ |
|||
from PIL import Image |
|||
import time |
|||
|
|||
i = 1 |
|||
|
|||
while True: |
|||
|
|||
page = Image.open("split/input%i.jpg"%i) |
|||
|
|||
if i % 2 == 0: |
|||
#check where the for loop is |
|||
print("trying even") |
|||
|
|||
#rotate image by 90 degrees |
|||
angle = 90 |
|||
out = page.rotate(angle, expand=True) |
|||
out.save('rotated/input%i.jpg'%i) |
|||
print('This is an even page number') |
|||
|
|||
time.sleep(2) |
|||
print("variable i: ", i) |
|||
|
|||
else: |
|||
#check where the for loop is |
|||
print("trying odd") |
|||
|
|||
#rotate image by 90 degrees |
|||
angle = 270 |
|||
out = page.rotate(angle, expand=True) |
|||
out.save('rotated/input%i.jpg'%i) |
|||
print('This is an odd page number') |
|||
|
|||
time.sleep(1) |
|||
print("variable i: ", i) |
|||
|
|||
i+=1 |
Binary file not shown.
@ -1,10 +1,12 @@ |
|||
mkdir split |
|||
mkdir rotated |
|||
mkdir ocred |
|||
mkdir bounding_box |
|||
mkdir cropped |
|||
./merge_scans.sh |
|||
python3 burstpdf.py |
|||
python3 rotation.py |
|||
python3 mask_crop.py |
|||
python3 bounding_box.py |
|||
python3 mirror_crop.py |
|||
python3 tesseract_ocr.py |
|||
./merge_files.sh |
|||
|
Loading…
Reference in new issue