Skip to content

Commit

Permalink
Grey -> Gray
Browse files Browse the repository at this point in the history
  • Loading branch information
alessiamarcolini authored and nicolebussola committed Aug 5, 2020
1 parent d5945e1 commit e42538a
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions src/histolab/filters/image_filters.py
Expand Up @@ -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):
Expand All @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions src/histolab/filters/image_filters_functional.py
Expand Up @@ -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.")
Expand All @@ -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.")
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/histolab/tile.py
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions tests/base.py
Expand Up @@ -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],
Expand All @@ -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],
Expand All @@ -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],
Expand All @@ -32,7 +32,7 @@
]
)

IMAGE4_GREY_WHITE = np.array(
IMAGE4_GRAY_WHITE = np.array(
[
[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1],
Expand Down
22 changes: 11 additions & 11 deletions tests/unit/test_util.py
Expand Up @@ -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,
Expand Down Expand Up @@ -237,7 +237,7 @@ def test_region_coordinates():
@pytest.fixture(
params=[
(
IMAGE1_GREY,
IMAGE1_GRAY,
160,
operator.gt,
np.array(
Expand All @@ -251,7 +251,7 @@ def test_region_coordinates():
),
),
(
IMAGE2_GREY,
IMAGE2_GRAY,
140,
operator.lt,
np.array(
Expand All @@ -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,
Expand Down

0 comments on commit e42538a

Please sign in to comment.