Detect if a text image is upside down
I have some hundreds of images (scanned documents), most of them are skewed. I wanted to de-skew them using Python. Here is the code I used: import numpy as np import cv2 from skimage.transform import radon filename = 'path_to_filename' # Load file, converting to grayscale img = cv2.imread(filename) I = cv2.cvtColor(img, COLOR_BGR2GRAY) h, w = I.shape # If the resolution is high, resize the image to reduce processing time. if (w > 640): I = cv2.resize(I, (640, int((h / w) * 640))) I = I - np.mean(I) # Demean; make the brightness extend above and below zero # Do the radon transform sinogram =