Skip to content
Snippets Groups Projects
Commit cc3df0c9 authored by tpylak's avatar tpylak
Browse files

LMS-2502 image transformations: mor robust transformation factories

SVN: 22932
parent cb016fb0
No related branches found
No related tags found
No related merge requests found
...@@ -51,6 +51,10 @@ public class AutoRescaleIntensityImageTransformerFactory implements IImageTransf ...@@ -51,6 +51,10 @@ public class AutoRescaleIntensityImageTransformerFactory implements IImageTransf
{ {
public BufferedImage transform(BufferedImage image) public BufferedImage transform(BufferedImage image)
{ {
if (IntensityRescaling.isNotGrayscale(image))
{
return image;
}
Levels levels = IntensityRescaling.computeLevels(image, threshold); Levels levels = IntensityRescaling.computeLevels(image, threshold);
return IntensityRescaling.rescaleIntensityLevelTo8Bits(image, levels); return IntensityRescaling.rescaleIntensityLevelTo8Bits(image, levels);
} }
......
...@@ -33,6 +33,10 @@ final class BitShiftingImageTransformerFactory implements IImageTransformerFacto ...@@ -33,6 +33,10 @@ final class BitShiftingImageTransformerFactory implements IImageTransformerFacto
{ {
public BufferedImage transform(BufferedImage image) public BufferedImage transform(BufferedImage image)
{ {
if (IntensityRescaling.isNotGrayscale(image))
{
return image;
}
return IntensityRescaling.rescaleIntensityBitShiftTo8Bits(image, shiftBits); return IntensityRescaling.rescaleIntensityBitShiftTo8Bits(image, shiftBits);
} }
}; };
......
...@@ -53,6 +53,10 @@ public class IntensityRangeImageTransformerFactory implements IImageTransformerF ...@@ -53,6 +53,10 @@ public class IntensityRangeImageTransformerFactory implements IImageTransformerF
{ {
public BufferedImage transform(BufferedImage image) public BufferedImage transform(BufferedImage image)
{ {
if (IntensityRescaling.isNotGrayscale(image))
{
return image;
}
Levels levels = new Levels(blackPointIntensity, whitePointIntensity); Levels levels = new Levels(blackPointIntensity, whitePointIntensity);
return IntensityRescaling.rescaleIntensityLevelTo8Bits(image, levels); return IntensityRescaling.rescaleIntensityLevelTo8Bits(image, levels);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment