How to load an image as ARGB type using Java?


#1

I load an image (.jpg type) using this Java code :
DatasetIOService datasetIOService = context.getService(DatasetIOService.class);
Dataset input = datasetIOService.open(filename);
and this is by default net.imglib2.type.numeric.integer.UnsignedByteType datatype.
But I need this to be loaded / converted to net.imglib2.type.numeric.ARGBType datatype.
Any ideas on what should be done?
Thanks in advance ! :slight_smile:


#2

Hi @ASHISRAVINDRAN,

Welcome to the forum.

Converters are your friend! Something like:

argbRAI = Converters.convert( ubyteRAI, new RealARGBConverter<T>());

should do the trick. Of course, this is for converting something thatโ€™s already been loaded, not for reading an image as ARGB.

See:
http://javadoc.scijava.org/ImgLib2/net/imglib2/converter/Converters.html
http://javadoc.scijava.org/ImgLib2/net/imglib2/converter/RealARGBConverter.html