path = "../Images/" filename = "signature.jpg" # Opening Image if len(filename.split('.')) == 2: image = cv2.imread(path + filename, 0) # Task 0 filename = path + "bin_" + filename bin_image = Task0.Binarization(image, filename) filename = filename.split('/')[-1] # Task 1 height, width = bin_image.shape filename = path + "box_" + filename top, bottom, left, right = Task1.BoundingBox(bin_image, height, width) bounding_box_image = cv2.rectangle(bin_image, (top, left), (bottom, right), (0,255,0), 3) cv2.imwrite(filename, bounding_box_image) B = (left, right, top, bottom) filename = filename.split('/')[-1] # Task 2 filename = path + "cen_" + filename cx, cy = Task2.FindCentroid(bin_image, 0, bin_image.shape[1], 0, bin_image.shape[0]) centroid_image = cv2.circle(bounding_box_image, (cy, cx), 10, 200, -1) cv2.imwrite(filename, centroid_image) C = (cx, cy) filename = filename.split('/')[-1]
filename = "signature.jpg" # Opening Image if len(filename.split('.')) == 2: image = cv2.imread(filename, 0) # Task 0 filename = "bin_" + filename bin_image = Task0.Binarization(image, filename) # cv2.imshow("Binarization", bin_image) # Task 1 width, height = bin_image.shape filename = "box_" + filename top, bottom, left, right, bounding_box_image = Task1.BoundingBox(width, height, bin_image, filename) B = (left, right, top, bottom) # cv2.imshow("Bounding Box", bounding_box_image) # Task 2 filename = "cen_" + filename centroid_image, cx, cy = Task2.FindCentroid(width, height, bin_image, bounding_box_image, filename) C = (cx, cy) # cv2.imshow("Centroid", centroid_image) # Task 3 cx = int(cx) cy = int(cy) filename = "seg_" + filename top_left, bottom_left, top_right, bottom_right, segmented_image = Task3.DivideBoundingBox(centroid_image, top, bottom, left, right, cx, cy, filename)