def get_projection(self, rows_expected=1): binary = cv2.adaptiveThreshold( self.image, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, Projection.to_odd(self.get_stroke_width(1) * 2), 5) # th, binary = cv2.threshold(self.image, 127, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU) self.latest_reference_image = binary binary[binary > 0] = 1 vector = np.sum(binary, axis=1 - self.orientation) assert len(vector) == self.measurement return Projection.normalize(vector)
def get_projection(self, rows_expected=1): binary = cv2.adaptiveThreshold( self.image, 255, cv2.ADAPTIVE_THRESH_MEAN_C, cv2.THRESH_BINARY_INV, Projection.to_odd(self.get_stroke_width(1) * 2), 5) # th, binary = cv2.threshold(self.image, 127, 255, cv2.THRESH_BINARY_INV + cv2.THRESH_OTSU) self.latest_reference_image = binary binary[binary > 0] = 1 vector = np.sum(binary, axis=1-self.orientation) assert len(vector) == self.measurement return Projection.normalize(vector)