#test.py | |
#import dependencies | |
import cv2 | |
import os | |
import MoCV | |
""" | |
_segment_image_test - function to test optimal thresholding for image segmentation | |
Parameters: | |
test_folder_path I/P path to test folder for image segmentation | |
test_img_name I/P name of test image | |
""" | |
def _segment_image_test(test_folder_path, img_name): | |
#read_image | |
img = cv2.imread(os.path.join(test_folder_path, img_name), 0) | |
#print image out | |
#cv2.imshow('original image', img) | |
#cv2.waitKey(0) | |
#cv2.destroyAllWindows() | |
#segment images front and back | |
front_img, back_img = MoCV.segmentation.optimal_thresholding(img) | |
front_img_path = os.path.join(test_folder_path, "front_segmented_img.png") | |
back_img_path = os.path.join(test_folder_path, "back_segmented_img.png") | |
#write front and back images | |
cv2.imwrite(front_img_path, front_img) | |
cv2.imwrite(back_img_path, back_img) | |
""" | |
test - function test all functions | |
Parameters: | |
mode I/P index of CV algorithsm for testing. Look at README for indices of algorithms. -1 for all algorithms | |
""" | |
_segment_image_test("path_to_image_folder, "name_of_image") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment