-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Description
Hi! I'm processing a large number of images. Based on the recommendation in #395, I set min_deviation to 0.1 to get a more precise rotation angle. However, it seems to have made the angle detection less precise.
This can be reproduced with images downloaded from Archive.org:
https://archive.org/download/stjerne8808dan/stjerne8808dan_jp2.zip
Here's some sample code:
import os
import numpy as np
from skimage import io
from skimage.color import rgb2gray
from skimage.transform import rotate
from deskew import determine_skew
input_directory = '/Users/sbradshaw/Downloads/stjerne8808dan_jp2'
output_directory = '/Users/sbradshaw/Downloads/stjerne8808dan_jp2-out'
os.makedirs(output_directory, exist_ok = True)
for filename in sorted(os.listdir(input_directory)):
if filename.endswith('.jp2'):
input_path = os.path.join(input_directory, filename)
image = io.imread(input_path)
grayscale = rgb2gray(image)
# Determine skew
angle = determine_skew(grayscale, min_deviation = 0.1)
rotated = rotate(image, angle, resize=True) * 255
output_path = os.path.join(output_directory, filename + '.jpg')
io.imsave(output_path, rotated.astype(np.uint8))
If I set min_deviation = 1, I get output like this:
But if I set min_deviation = 0.1, I get output like this:
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

