From f792f177522adbd46d78f0149eabe19316170f4e Mon Sep 17 00:00:00 2001 From: "ogueler@idiap.ch" <ogueler@vws110.idiap.ch> Date: Mon, 3 Apr 2023 21:48:08 +0200 Subject: [PATCH] removed redundant custom transform function --- .../datasets/tbx11k_simplified/__init__.py | 2 +- src/ptbench/data/transforms.py | 33 ------------------- 2 files changed, 1 insertion(+), 34 deletions(-) diff --git a/src/ptbench/configs/datasets/tbx11k_simplified/__init__.py b/src/ptbench/configs/datasets/tbx11k_simplified/__init__.py index 277fd087..f52f2db1 100644 --- a/src/ptbench/configs/datasets/tbx11k_simplified/__init__.py +++ b/src/ptbench/configs/datasets/tbx11k_simplified/__init__.py @@ -19,7 +19,7 @@ def _maker(protocol, RGB=False): return mk( [raw.subsets(protocol)], - [RGBtoGreyscale8bit()], + [], [ElasticDeformation(p=0.8)], post_transforms, ) diff --git a/src/ptbench/data/transforms.py b/src/ptbench/data/transforms.py index 031bde89..c1f1f7d0 100644 --- a/src/ptbench/data/transforms.py +++ b/src/ptbench/data/transforms.py @@ -42,39 +42,6 @@ class SingleAutoLevel16to8: ).convert("L") -class RGBtoGreyscale8bit: - """Converts a 24-bit RGB image to an 8-bit greyscale representation. - - This transform assumes that the input image is RGB with 24 bits. - - Converts the RGB image to a greyscale image using the well-known formula: - Y = 0.299 * R + 0.587 * G + 0.114 * B - This formula is based on the relative luminance of the RGB channels in the sRGB color space - - consider such a range should be mapped to the [0,255] range of the - destination image. - """ - - def __call__(self, img): - # Use the formula to convert the RGB image to a greyscale image - img_array = numpy.array(img).astype(float) - grey_array = ( - 0.299 * img_array[:, :, 0] - + 0.587 * img_array[:, :, 1] - + 0.114 * img_array[:, :, 2] - ) - - # Normalize the greyscale image to the range [0, 255] and convert it to uint8 - grey_array = numpy.round( - 255.0 - * (grey_array - grey_array.min()) - / (grey_array.max() - grey_array.min()) - ).astype("uint8") - - # Create a new greyscale PIL image from the normalized array - return PIL.Image.fromarray(grey_array).convert("L") - - class RemoveBlackBorders: """Remove black borders of CXR.""" -- GitLab