def morphology_week5(images, conn, prints=True): if prints: t = time.time() sys.stdout.write('Computing morphology... ') kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (10, 10)) results = morph.Closing(images, kernel, False) results = hole_filling(results,conn, False) kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (13, 13)) results = morph.Opening(results, kernel, False) if prints: elapsed = time.time() - t sys.stdout.write(str(elapsed) + ' sec \n') return results
def task3_morphology_highway(train, test, test_GT, alpha, ro, conn, p, prints=True, valid_pixels=None): results = background_substraction(train, test, alpha, ro, prints) results = hole_filling(results,conn, prints) if valid_pixels != None: for i in range(len(results)): results[i][valid_pixels] = 0 results = area_filtering(results, p, prints) kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (7, 7)) results = morph.Closing(results, kernel, prints) results = hole_filling(results,conn, prints) kernel = cv2.getStructuringElement(cv2.MORPH_RECT, (7, 1)) results = morph.Opening(results, kernel, prints) metrics = results_evaluation(results, test_GT, prints) return results, metrics