From cc3df0c9f6858259c13dae811afbec32773ef48f Mon Sep 17 00:00:00 2001 From: tpylak <tpylak> Date: Tue, 13 Sep 2011 22:58:34 +0000 Subject: [PATCH] LMS-2502 image transformations: mor robust transformation factories SVN: 22932 --- .../AutoRescaleIntensityImageTransformerFactory.java | 4 ++++ .../transformations/BitShiftingImageTransformerFactory.java | 4 ++++ .../IntensityRangeImageTransformerFactory.java | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dto/api/v1/transformations/AutoRescaleIntensityImageTransformerFactory.java b/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dto/api/v1/transformations/AutoRescaleIntensityImageTransformerFactory.java index 06e0c6acbcd..c952a10645c 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dto/api/v1/transformations/AutoRescaleIntensityImageTransformerFactory.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dto/api/v1/transformations/AutoRescaleIntensityImageTransformerFactory.java @@ -51,6 +51,10 @@ public class AutoRescaleIntensityImageTransformerFactory implements IImageTransf { public BufferedImage transform(BufferedImage image) { + if (IntensityRescaling.isNotGrayscale(image)) + { + return image; + } Levels levels = IntensityRescaling.computeLevels(image, threshold); return IntensityRescaling.rescaleIntensityLevelTo8Bits(image, levels); } diff --git a/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dto/api/v1/transformations/BitShiftingImageTransformerFactory.java b/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dto/api/v1/transformations/BitShiftingImageTransformerFactory.java index b036a1046c5..801b2849a68 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dto/api/v1/transformations/BitShiftingImageTransformerFactory.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dto/api/v1/transformations/BitShiftingImageTransformerFactory.java @@ -33,6 +33,10 @@ final class BitShiftingImageTransformerFactory implements IImageTransformerFacto { public BufferedImage transform(BufferedImage image) { + if (IntensityRescaling.isNotGrayscale(image)) + { + return image; + } return IntensityRescaling.rescaleIntensityBitShiftTo8Bits(image, shiftBits); } }; diff --git a/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dto/api/v1/transformations/IntensityRangeImageTransformerFactory.java b/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dto/api/v1/transformations/IntensityRangeImageTransformerFactory.java index 5c3207ddec4..cf385e641d0 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dto/api/v1/transformations/IntensityRangeImageTransformerFactory.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dto/api/v1/transformations/IntensityRangeImageTransformerFactory.java @@ -53,6 +53,10 @@ public class IntensityRangeImageTransformerFactory implements IImageTransformerF { public BufferedImage transform(BufferedImage image) { + if (IntensityRescaling.isNotGrayscale(image)) + { + return image; + } Levels levels = new Levels(blackPointIntensity, whitePointIntensity); return IntensityRescaling.rescaleIntensityLevelTo8Bits(image, levels); } -- GitLab