def calculate_single_weight(self, angle): """Finds the strongest gradient in the image""" obj = ShearTool(self.img) corrected = obj.shear(angle) p = BinaryProjection(corrected, Projection.TYPE_HORIZONTAL) # p.debug() return max(np.gradient(p.get_projection())) + abs(min(np.gradient(p.get_projection())))
def normalize_font(self, angle): obj = ShearTool(self.img) return obj.shear(angle)