- Code: Select all
ImagePlus[] images = BF.openImagePlus("...") ;
But the ImagePlus generated contains a ByteProcessor that can only code a 8-bit image. I checked, and indeed there is only 1 channel. The BufferedImage generated from the ByteProcessor is logically a TYPE_BYTE_GRAY.
By default, that code will return each channel as a separate plane in the ImagePlus; images[0].getNChannels() gives the number of detected channels, which for something like an RGB JPEG image will be 3.
The way in which the channels are handled, and how files are opened in general, can be configured using the loci.plugins.in.ImporterOptions class in combination with the BF.openImagePlus(ImporterOptions) signature. If your end goal is an RGB BufferedImage, then this would be a place to start:
- Code: Select all
ImporterOptions options = new ImporterOptions();
options.setId("/path/to/file");
options.setColorMode(ImporterOptions.COLOR_MODE_COMPOSITE);
ImagePlus[] images = BF.openImagePlus(options);
CompositeImage ci = (CompositeImage) images[0];
Image img = ci.getImage();
If that doesn't work, then it would be helpful to know more about the file that you're trying to open (e.g. format and expected number of channels).