diff --git a/src/histolab/filters/image_filters.py b/src/histolab/filters/image_filters.py index 1357f0bd..dd93e6c2 100644 --- a/src/histolab/filters/image_filters.py +++ b/src/histolab/filters/image_filters.py @@ -170,7 +170,7 @@ class HematoxylinChannel(object): Returns ------- Image.Image - Greyscale image corresponding to input image with Hematoxylin channel enhanced. + Grayscale image corresponding to input image with Hematoxylin channel enhanced. """ def __call__(self, img): @@ -195,7 +195,7 @@ class EosinChannel(object): Returns ------- Image.Image - Greyscale image corresponding to input image with Eosin channel enhanced. + Grayscale image corresponding to input image with Eosin channel enhanced. """ def __call__(self, img): @@ -468,7 +468,7 @@ def __repr__(self) -> str: class HysteresisThresholdMask(object): """Mask an image using hysteresis threshold - Compute the Hysteresis threshold on the complement of a greyscale image, + Compute the Hysteresis threshold on the complement of a grayscale image, and return boolean mask based on pixels above this threshold. Parameters @@ -634,7 +634,7 @@ def __repr__(self) -> str: class Grays(object): """Filter out gray pixels in RGB image. - Grey pixels are those pixels where the red, green, and blue channel values + Gray pixels are those pixels where the red, green, and blue channel values are similar, i.e. under a specified tolerance. Parameters diff --git a/src/histolab/filters/image_filters_functional.py b/src/histolab/filters/image_filters_functional.py index da8be880..4aaf900e 100644 --- a/src/histolab/filters/image_filters_functional.py +++ b/src/histolab/filters/image_filters_functional.py @@ -109,7 +109,7 @@ def hematoxylin_channel(img: PIL.Image.Image) -> PIL.Image.Image: Returns ------- Image.Image - Greyscale image corresponding to input image with Hematoxylin channel enhanced. + Grayscale image corresponding to input image with Hematoxylin channel enhanced. """ if img.mode not in ["RGB", "RGBA"]: raise ValueError("Input image must be RGB/RGBA.") @@ -132,7 +132,7 @@ def eosin_channel(img: PIL.Image.Image) -> PIL.Image.Image: Returns ------- Image.Image - Greyscale image corresponding to input image with Eosin channel enhanced. + Grayscale image corresponding to input image with Eosin channel enhanced. """ if img.mode not in ["RGB", "RGBA"]: raise ValueError("Input image must be RGB/RGBA.") @@ -164,7 +164,7 @@ def rgb_to_hsv(img: PIL.Image.Image) -> PIL.Image.Image: return hsv -# TODO setup logger warning + greyscale --> invert ---> contrast stretch +# TODO setup logger warning + grayscale --> invert ---> contrast stretch def stretch_contrast( @@ -523,7 +523,7 @@ def hysteresis_threshold_mask( ) -> np.ndarray: """Mask an image using hysteresis threshold - Compute the Hysteresis threshold on the complement of a greyscale image, + Compute the Hysteresis threshold on the complement of a grayscale image, and return boolean mask based on pixels above this threshold. Parameters @@ -575,7 +575,7 @@ def otsu_threshold( image = PIL.ImageOps.grayscale(img) warn( "otsu_threshold is expected to work correctly only for grayscale images." - "NOTE: the image will be converted to greyscale before applying Otsu" + "NOTE: the image will be converted to grayscale before applying Otsu" "threshold" ) else: @@ -622,7 +622,7 @@ def filter_entropy( return threshold_to_mask(entropy, threshold, relate) -# input of canny filter is a greyscale +# input of canny filter is a grayscale def canny_edges( img: PIL.Image.Image, sigma: float = 1.0, @@ -659,7 +659,7 @@ def canny_edges( def grays(img: PIL.Image.Image, tolerance: int = 15) -> np.ndarray: """Filter out gray pixels in RGB image. - Grey pixels are those pixels where the red, green, and blue channel values + Gray pixels are those pixels where the red, green, and blue channel values are similar, i.e. under a specified tolerance. Parameters diff --git a/src/histolab/tile.py b/src/histolab/tile.py index 4331acdb..01bb3743 100644 --- a/src/histolab/tile.py +++ b/src/histolab/tile.py @@ -145,8 +145,8 @@ def _is_almost_white(self) -> bool: bool True if the image is almost white, False otherwise """ - rgb2grey = imf.RgbToGrayscale() - image_gray = rgb2grey(self._image) + rgb2gray = imf.RgbToGrayscale() + image_gray = rgb2gray(self._image) image_gray_arr = np.array(image_gray) image_gray_arr = image_gray_arr / 255 diff --git a/tests/base.py b/tests/base.py index 1e93ed22..4c6fc660 100644 --- a/tests/base.py +++ b/tests/base.py @@ -2,7 +2,7 @@ import sparse # ============== IMAGES ============== -IMAGE1_GREY = np.array( +IMAGE1_GRAY = np.array( [ [152, 100, 162, 160, 23], [160, 113, 31, 126, 36], @@ -12,7 +12,7 @@ ] ) -IMAGE2_GREY = np.array( +IMAGE2_GRAY = np.array( [ [89.04472016, 70.10608259, 233.5658837, 165.17043321, 2.37055166], [73.56836436, 222.25117531, 73.54528918, 246.26874863, 201.15243113], @@ -22,7 +22,7 @@ ] ).astype("float64") -IMAGE3_GREY_BLACK = np.array( +IMAGE3_GRAY_BLACK = np.array( [ [0, 0, 0, 0, 0], [0, 0, 0, 0, 0], @@ -32,7 +32,7 @@ ] ) -IMAGE4_GREY_WHITE = np.array( +IMAGE4_GRAY_WHITE = np.array( [ [1, 1, 1, 1, 1], [1, 1, 1, 1, 1], diff --git a/tests/unit/test_util.py b/tests/unit/test_util.py index f934ca3e..d8a79cbc 100644 --- a/tests/unit/test_util.py +++ b/tests/unit/test_util.py @@ -7,16 +7,16 @@ import numpy as np import pytest from tests.base import ( - IMAGE1_GREY, + IMAGE1_GRAY, IMAGE1_RGB, IMAGE1_RGBA, - IMAGE2_GREY, + IMAGE2_GRAY, IMAGE2_RGB, IMAGE2_RGBA, - IMAGE3_GREY_BLACK, + IMAGE3_GRAY_BLACK, IMAGE3_RGB_BLACK, IMAGE3_RGBA_BLACK, - IMAGE4_GREY_WHITE, + IMAGE4_GRAY_WHITE, IMAGE4_RGB_WHITE, IMAGE4_RGBA_WHITE, SPARSE_BASE_MASK, @@ -237,7 +237,7 @@ def test_region_coordinates(): @pytest.fixture( params=[ ( - IMAGE1_GREY, + IMAGE1_GRAY, 160, operator.gt, np.array( @@ -251,7 +251,7 @@ def test_region_coordinates(): ), ), ( - IMAGE2_GREY, + IMAGE2_GRAY, 140, operator.lt, np.array( @@ -264,11 +264,11 @@ def test_region_coordinates(): ] ), ), - (IMAGE3_GREY_BLACK, 0, operator.gt, np.zeros((5, 5), dtype=bool)), - (IMAGE3_GREY_BLACK, 0, operator.lt, np.zeros((5, 5), dtype=bool)), - (IMAGE3_GREY_BLACK, 1, operator.lt, np.ones((5, 5), dtype=bool)), - (IMAGE4_GREY_WHITE, 0, operator.gt, np.ones((5, 5), dtype=bool)), - (IMAGE4_GREY_WHITE, 1, operator.lt, np.zeros((5, 5), dtype=bool)), + (IMAGE3_GRAY_BLACK, 0, operator.gt, np.zeros((5, 5), dtype=bool)), + (IMAGE3_GRAY_BLACK, 0, operator.lt, np.zeros((5, 5), dtype=bool)), + (IMAGE3_GRAY_BLACK, 1, operator.lt, np.ones((5, 5), dtype=bool)), + (IMAGE4_GRAY_WHITE, 0, operator.gt, np.ones((5, 5), dtype=bool)), + (IMAGE4_GRAY_WHITE, 1, operator.lt, np.zeros((5, 5), dtype=bool)), ( IMAGE1_RGB, 200,