diff --git a/src/data_processing.py b/src/data_processing.py index daa4a7a..3cd9e2d 100644 --- a/src/data_processing.py +++ b/src/data_processing.py @@ -37,6 +37,8 @@ def store_data(filenames, input_path, output_path): print(error_message) def main(): + if not os.path.exists(sys.argv[1]): + raise ValueError("The image files doesn't Exists. Please review your file path") dir = sys.argv[1] input_filepaths = get_file_names(dir) output_filepath = sys.argv[2] diff --git a/src/image_alignment.py b/src/image_alignment.py index 6bab7f9..bd3aa71 100644 --- a/src/image_alignment.py +++ b/src/image_alignment.py @@ -1,5 +1,5 @@ import sys - +import os.path import cv2 import numpy as np import image_shapes as shapes @@ -90,6 +90,8 @@ def align_images(petal_img, vein_img, raw_vein=True): def main(): if (len(sys.argv) < 3): raise ValueError("Usage: image_alignment.py ") + if not (os.path.exists(sys.argv[1]) and os.path.exists(sys.argv[2])): + raise ValueError("One of the image files doesn't Exists. Please review your file paths \n Usage: image.alignment.py ") petal_image = cv2.imread(sys.argv[1]) vein_image = cv2.imread(sys.argv[2], cv2.IMREAD_GRAYSCALE) (petal_shape, vein_aligned) = align_images(petal_image, vein_image) diff --git a/src/imgrab.py b/src/imgrab.py index 7c9b5bf..4067ac2 100644 --- a/src/imgrab.py +++ b/src/imgrab.py @@ -1,10 +1,13 @@ import principal_component as p import sys +import os.path import cv2 from skimage import io def main(): + if not os.path.exists(sys.argv[1]): + raise ValueError("The image files doesn't Exists. Please review your file path") image = cv2.imread(sys.argv[1]) im = vein_image = cv2.imread(sys.argv[1], cv2.IMREAD_GRAYSCALE) i = p.pca_to_grey(image) diff --git a/src/principal_component.py b/src/principal_component.py index 8834bf3..7eff42c 100644 --- a/src/principal_component.py +++ b/src/principal_component.py @@ -1,5 +1,6 @@ import sys import cv2 +import os.path import matplotlib.pyplot as plt import numpy as np import image_shapes as shapes @@ -59,6 +60,8 @@ def create_point_cloud(image): if len(sys.argv) < 2: print("Standalone usage: python principal_component.py input_filename.jpg [output_filename.jpg]") sys.exit(1) + if not os.path.exists(sys.argv[1]): + raise ValueError("One of the image files doesn't Exists. Please review your file paths") petal_image = cv2.imread(sys.argv[1]) petal_shape = shapes.get_petal_shape(petal_image) result = pca_to_grey(petal_image, petal_shape, True) @@ -66,4 +69,4 @@ def create_point_cloud(image): cv2.imwrite(sys.argv[2], result) else: io.imshow(result) - io.show() \ No newline at end of file + io.show() diff --git a/src/spot_detection.py b/src/spot_detection.py index 1df4367..ffc3712 100644 --- a/src/spot_detection.py +++ b/src/spot_detection.py @@ -1,5 +1,5 @@ import sys - +import os.path import matplotlib.pyplot as plt import numpy as np from sklearn.mixture import BayesianGaussianMixture @@ -56,6 +56,8 @@ def overlay_spotting_events_on_image(image, model): plt.show() def main(): + if not os.path.exists(sys.argv[1]): + raise ValueError("The image files doesn't Exists. Please review your file path") image = imread(sys.argv[1]) image = iu.resize_image(image, 400)