0

I need to I/O large images in TIFF format, so I need to use the BigTIFF format. I tried to use BioFormats (bioformats_package.jar) last version to read an image, using:

ImagePlus[] images = images = BF.openImagePlus(io) ;

Then, I wanted to access the Processor images[0].getProcessor() to modify/access the pixel values, but the result appears to not be any of the classical ImageJ processor: ByteProcessor, ColorProcessor, FloatProcessor, and ShortProcessor. I tested ALL of them using instanceof.

Any idea what type of Processor it could be?

Or how I would access the pixel values?

[EDIT] I still don't know what type of ImageProcessor the result is, but I found out that the saved pixels are encoded using Float, so 32 bits.

This is not ideal as I saved an image using Integer encoding, so there is a loss of precision when values are bigger than 20 millions.

FiReTiTi
  • 5,597
  • 12
  • 30
  • 58

1 Answers1

0

According to the JavaDocs on ImagePlus, getProcessor() returns an ImageProcessor on which you can perform a convertToByteProcessor() to get a ByteProcessor, you have other converters on ImageProcessor for other subclasses.

thecarpy
  • 845
  • 11
  • 24
  • Agreed. This `ImageProcessor` is supposed to be an instance of one of the four classes I listed, but it's not. – FiReTiTi Apr 29 '22 at 22:31
  • Please post more code, then, I fail to understand what the problem is ... you actually have to do `images[0].getProcessor().convertToByteProcessor()` to get a `ByteProcessor` but I guess you already know that and so I do not understand your problem. You asked what type of Processor, I claim `ImageProcessor` that you have to convert to your preferred processor. My understanding is you want `ByteProcessor.getPixels()` – thecarpy Apr 29 '22 at 22:38
  • You do `convertToByteProcessor`if your `ImageProcessor` is indeed a ByteProcessor`, but it can also be another type of processor. That's what I'm saying, when reading a `BigTIFF`, the `ImageProcessor` has an encoding that is different and I don't know which one. – FiReTiTi Apr 29 '22 at 23:49