From b7735644464e48aae3f5a6b41f9acd7a99ed20af Mon Sep 17 00:00:00 2001 From: igraf <igraf@cl.uni-heidelberg.de> Date: Fri, 23 Feb 2024 18:05:54 +0100 Subject: [PATCH] Add alternative way to read image --- project/minimal_examples/apply_filters.py | 7 ++++--- project/minimal_examples/extract_features.py | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/project/minimal_examples/apply_filters.py b/project/minimal_examples/apply_filters.py index 859f9c8..383358b 100644 --- a/project/minimal_examples/apply_filters.py +++ b/project/minimal_examples/apply_filters.py @@ -8,18 +8,19 @@ from skimage.io import imread from skimage.filters import sobel # Read image from file -image = imread("../figures/examples_from_dataset/banana.jpg", as_gray=False) +image = cv2.imread("../figures/examples_from_dataset/banana.jpg") +#image = imread("../figures/examples_from_dataset/banana.jpg", as_gray=False) # Alternative way to read image # Resizing image to 50x50 image_resized = cv2.resize(image, (50, 50)) cv2.imwrite('../figures/examples_from_dataset/banana-resized.jpg', image_resized) # Use Canny edge detection filter and save to file -edge_img = cv2.Canny(image, threshold1=50, threshold2=80) +edge_img = cv2.Canny(image, threshold1=150, threshold2=300) cv2.imwrite('../figures/examples_from_dataset/banana-edges.jpg', edge_img) # Use Canny edge detection filter for resized image and save to file -edge_img_resized = cv2.Canny(image_resized, threshold1=50, threshold2=80) +edge_img_resized = cv2.Canny(image_resized, threshold1=150, threshold2=300) cv2.imwrite('../figures/examples_from_dataset/banana-edges-resized.jpg', edge_img_resized) # Use sobel filter and save to file diff --git a/project/minimal_examples/extract_features.py b/project/minimal_examples/extract_features.py index 4ae5547..a08a7f0 100644 --- a/project/minimal_examples/extract_features.py +++ b/project/minimal_examples/extract_features.py @@ -12,6 +12,7 @@ from skimage.io import imread # Read image from file image = imread("../figures/examples_from_dataset/banana.jpg", as_gray=False) +# image = cv2.imread("../figures/examples_from_dataset/banana.jpg") # Alternative way to read image print("Shape of original image: ", image.shape) # Save features in file -- GitLab