Skip to content

Reduced accuracy when min_deviation is set to 0.1 #625

@samuelbradshaw

Description

@samuelbradshaw

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:

Image

But if I set min_deviation = 0.1, I get output like this:

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions