From c686cc5863c2ac2530ed1f34bd9ce758bb17945a Mon Sep 17 00:00:00 2001 From: "Marvin M. Michum" Date: Thu, 8 Aug 2019 11:59:15 -0400 Subject: [PATCH] fix outdated fork error (#1117) --- .../filters/median_filter.py | 2 +- .../test_digital_image_processing.py | 62 +++++++++++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 digital_image_processing/test_digital_image_processing.py diff --git a/digital_image_processing/filters/median_filter.py b/digital_image_processing/filters/median_filter.py index ed20b1ab7..4b21b96b0 100644 --- a/digital_image_processing/filters/median_filter.py +++ b/digital_image_processing/filters/median_filter.py @@ -15,7 +15,7 @@ def median_filter(gray_img, mask=3): # set image borders bd = int(mask / 2) # copy image size - median_img = zeros_like(gray) + median_img = zeros_like(gray_img) for i in range(bd, gray_img.shape[0] - bd): for j in range(bd, gray_img.shape[1] - bd): # get mask according with mask diff --git a/digital_image_processing/test_digital_image_processing.py b/digital_image_processing/test_digital_image_processing.py new file mode 100644 index 000000000..0ff9e3333 --- /dev/null +++ b/digital_image_processing/test_digital_image_processing.py @@ -0,0 +1,62 @@ +""" +PyTest's for Digital Image Processing +""" + +import digital_image_processing.edge_detection.canny as canny +import digital_image_processing.filters.gaussian_filter as gg +import digital_image_processing.filters.median_filter as med +import digital_image_processing.filters.sobel_filter as sob +import digital_image_processing.filters.convolve as conv +import digital_image_processing.change_contrast as cc +from cv2 import imread, cvtColor, COLOR_BGR2GRAY +from numpy import array, uint8 +from PIL import Image + +img = imread(r"digital_image_processing/image_data/lena.jpg") +gray = cvtColor(img, COLOR_BGR2GRAY) + +# Test: change_contrast() +def test_change_contrast(): + with Image.open("digital_image_processing/image_data/lena.jpg") as img: + # Work around assertion for response + assert str(cc.change_contrast(img, 110)).startswith( + "