diff --git a/src/ptbench/configs/datasets/tbx11k_simplified/__init__.py b/src/ptbench/configs/datasets/tbx11k_simplified/__init__.py index 277fd087148c1c989b49a0766e51325aaf0a34e6..f52f2db110f7ca533d32e300f2309ffab3f14584 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 031bde8912a111039f3e103b278fa04f7b82249c..c1f1f7d0a4457fb441ddfefa5bd53c9e57bd2a60 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."""