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

LMS-2502 image transformations: minor refactoring

SVN: 22933
parent cc3df0c9
No related branches found
No related tags found
No related merge requests found
...@@ -40,7 +40,6 @@ import ch.systemsx.cisd.common.filesystem.FileUtilities; ...@@ -40,7 +40,6 @@ import ch.systemsx.cisd.common.filesystem.FileUtilities;
import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogCategory;
import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.common.logging.LogFactory;
import ch.systemsx.cisd.common.utilities.PropertyUtils; import ch.systemsx.cisd.common.utilities.PropertyUtils;
import ch.systemsx.cisd.imagereaders.ImageID;
import ch.systemsx.cisd.openbis.dss.etl.dto.api.v1.Channel; import ch.systemsx.cisd.openbis.dss.etl.dto.api.v1.Channel;
import ch.systemsx.cisd.openbis.dss.etl.dto.api.v1.ImageFileInfo; import ch.systemsx.cisd.openbis.dss.etl.dto.api.v1.ImageFileInfo;
import ch.systemsx.cisd.openbis.dss.etl.dto.api.v1.ImageIdentifier; import ch.systemsx.cisd.openbis.dss.etl.dto.api.v1.ImageIdentifier;
...@@ -472,7 +471,8 @@ abstract public class AbstractImageFileExtractor implements IImageFileExtractor ...@@ -472,7 +471,8 @@ abstract public class AbstractImageFileExtractor implements IImageFileExtractor
{ {
RelativeImageReference relativeImageRef = RelativeImageReference relativeImageRef =
new RelativeImageReference(imageInfo.getImageRelativePath(), new RelativeImageReference(imageInfo.getImageRelativePath(),
getImageID(imageInfo.tryGetImageIdentifier()), colorComponentOrNull); getUniqueStringIdentifier(imageInfo.tryGetImageIdentifier()),
colorComponentOrNull);
Location wellLoc = null; Location wellLoc = null;
if (imageInfo.hasWellLocation()) if (imageInfo.hasWellLocation())
{ {
...@@ -486,15 +486,14 @@ abstract public class AbstractImageFileExtractor implements IImageFileExtractor ...@@ -486,15 +486,14 @@ abstract public class AbstractImageFileExtractor implements IImageFileExtractor
return new AcquiredSingleImage(wellLoc, tileLoc, channelCode, imageInfo.tryGetTimepoint(), return new AcquiredSingleImage(wellLoc, tileLoc, channelCode, imageInfo.tryGetTimepoint(),
imageInfo.tryGetDepth(), imageInfo.tryGetSeriesNumber(), relativeImageRef); imageInfo.tryGetDepth(), imageInfo.tryGetSeriesNumber(), relativeImageRef);
} }
private static String getImageID(ImageIdentifier identifier) private static String getUniqueStringIdentifier(ImageIdentifier identifier)
{ {
if (identifier == null) if (identifier == null)
{ {
return null; return null;
} }
return new ImageID(identifier.getSeriesIndex(), identifier.getTimeSeriesIndex(), return identifier.getUniqueStringIdentifier();
identifier.getFocalPlaneIndex(), identifier.getColorChannelIndex()).getID();
} }
protected static Integer tryAsInt(String valueOrNull) protected static Integer tryAsInt(String valueOrNull)
......
...@@ -190,7 +190,7 @@ class Hdf5ThumbnailGenerator implements IHDF5WriterClient ...@@ -190,7 +190,7 @@ class Hdf5ThumbnailGenerator implements IHDF5WriterClient
private byte[] generateThumbnailInternally(File imageFile, String imageIdOrNull, private byte[] generateThumbnailInternally(File imageFile, String imageIdOrNull,
ByteArrayOutputStream bufferOutputStream) throws IOException ByteArrayOutputStream bufferOutputStream) throws IOException
{ {
BufferedImage image = loadImage(imageFile, imageIdOrNull); BufferedImage image = loadUnchangedImage(imageFile, imageIdOrNull);
BufferedImage thumbnail = BufferedImage thumbnail =
ImageUtil.rescale(image, thumbnailsStorageFormat.getMaxWidth(), ImageUtil.rescale(image, thumbnailsStorageFormat.getMaxWidth(),
thumbnailsStorageFormat.getMaxHeight(), false, thumbnailsStorageFormat.getMaxHeight(), false,
...@@ -199,10 +199,10 @@ class Hdf5ThumbnailGenerator implements IHDF5WriterClient ...@@ -199,10 +199,10 @@ class Hdf5ThumbnailGenerator implements IHDF5WriterClient
return bufferOutputStream.toByteArray(); return bufferOutputStream.toByteArray();
} }
private BufferedImage loadImage(File imageFile, String imageIdOrNull) private BufferedImage loadUnchangedImage(File imageFile, String imageIdOrNull)
{ {
return AbsoluteImageReference.loadUnchangedImage(new FileBasedContent(imageFile), imageIdOrNull, return AbsoluteImageReference.loadUnchangedImage(new FileBasedContent(imageFile),
imageLibraryOrNull); imageIdOrNull, imageLibraryOrNull);
} }
private Status createStatus(String thumbnailPath, IOException ex) private Status createStatus(String thumbnailPath, IOException ex)
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
package ch.systemsx.cisd.openbis.dss.etl.dto.api.v1; package ch.systemsx.cisd.openbis.dss.etl.dto.api.v1;
import ch.systemsx.cisd.imagereaders.ImageID;
/** /**
* Immutable value class of an image ID based on series index, time series index, focal plane index, * Immutable value class of an image ID based on series index, time series index, focal plane index,
* and color channel index. It will be used to identify images in a container image file format like * and color channel index. It will be used to identify images in a container image file format like
...@@ -26,7 +28,7 @@ package ch.systemsx.cisd.openbis.dss.etl.dto.api.v1; ...@@ -26,7 +28,7 @@ package ch.systemsx.cisd.openbis.dss.etl.dto.api.v1;
public class ImageIdentifier implements Comparable<ImageIdentifier> public class ImageIdentifier implements Comparable<ImageIdentifier>
{ {
public static final ImageIdentifier NULL = new ImageIdentifier(0, 0, 0, 0); public static final ImageIdentifier NULL = new ImageIdentifier(0, 0, 0, 0);
private final int seriesIndex; private final int seriesIndex;
private final int timeSeriesIndex; private final int timeSeriesIndex;
...@@ -34,7 +36,7 @@ public class ImageIdentifier implements Comparable<ImageIdentifier> ...@@ -34,7 +36,7 @@ public class ImageIdentifier implements Comparable<ImageIdentifier>
private final int focalPlaneIndex; private final int focalPlaneIndex;
private final int colorChannelIndex; private final int colorChannelIndex;
/** /**
* Creates an instance for the specified series index, time series (or T) index, focal plane (or * Creates an instance for the specified series index, time series (or T) index, focal plane (or
* Z) index, color channel index. * Z) index, color channel index.
...@@ -68,6 +70,12 @@ public class ImageIdentifier implements Comparable<ImageIdentifier> ...@@ -68,6 +70,12 @@ public class ImageIdentifier implements Comparable<ImageIdentifier>
return colorChannelIndex; return colorChannelIndex;
} }
public String getUniqueStringIdentifier()
{
return new ImageID(getSeriesIndex(), getTimeSeriesIndex(), getFocalPlaneIndex(),
getColorChannelIndex()).getID();
}
public int compareTo(ImageIdentifier that) public int compareTo(ImageIdentifier that)
{ {
int diff = seriesIndex - that.seriesIndex; int diff = seriesIndex - that.seriesIndex;
......
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