Commit 04772c46 authored by danyfel80's avatar danyfel80
Browse files

fixed image reading bug on the image.

parent 29c5ee40
......@@ -31,6 +31,9 @@ import icy.image.IcyBufferedImage;
import icy.image.colormap.IcyColorMap;
import icy.image.colormap.LinearColorMap;
import icy.sequence.Sequence;
import icy.type.DataType;
import icy.type.collection.array.Array1DUtil;
import icy.type.collection.array.ByteArrayConvert;
import icy.type.dimension.Dimension2D;
import icy.type.dimension.Dimension2D.Double;
import loci.formats.FormatException;
......@@ -234,28 +237,68 @@ public class WellPlateReader_ColumbusOperaFlex extends AbstractWellPlateReader
{
String folderPath = plate.getFolder();
String flexFile = ch.getImage().getUrl();
String fullFilePath = Paths.get(folderPath, flexFile).toString();
ColumbusImage image = ch.getImage();
channelNames.put((int) ch.getId(), ch.getName());
IcyColorMap colorMap = new LinearColorMap(((int) ch.getEmissionWavelength()) + "nm", ch.getColor());
channelColors.put((int) ch.getId(), colorMap);
pixelSize.setSize(image.getResolutionX(), image.getResolutionY());
MinimalTiffReader reader = new MinimalTiffReader();
try
{
reader.setId(fullFilePath);
byte[] bytes = reader.openBytes((int) ch.getImage().getBufferNumber());
return new IcyBufferedImage((int) ch.getImage().getSizeX(), (int) ch.getImage().getSizeY(), bytes);
return loadIcyBufferedImage(reader, (int) ch.getImage().getBufferNumber(), (int) ch.getImage().getSizeX(),
(int) ch.getImage().getSizeY());
}
catch (FormatException e)
{
throw new IOException(e);
} finally {
}
finally
{
reader.close();
}
}
/**
* Loads the channel image from the reader at the given series with the given size.
*
* @param reader
* Image reader
* @param series
* The series to load
* @param sizeX
* Size X
* @param sizeY
* Size Y
* @return The channel image.
* @throws IOException
* If there is a problem reading the file.
*/
private IcyBufferedImage loadIcyBufferedImage(MinimalTiffReader reader, int series, int sizeX, int sizeY)
throws IOException
{
final DataType dataType = DataType.getDataTypeFromFormatToolsType(reader.getPixelType());
final boolean little = reader.isLittleEndian();
byte[] bytes;
try
{
bytes = reader.openBytes(series);
}
catch (FormatException e)
{
throw new IOException(e);
}
Object pixelData = Array1DUtil.createArray(dataType, sizeX * sizeY);
ByteArrayConvert.byteArrayTo(bytes, 0, pixelData, 0, bytes.length, little);
return new IcyBufferedImage(sizeX, sizeY, pixelData, dataType.isSigned());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment