AIOOB exception using 3D Median on virtual stack

I get the following exception when running the Median 3D filter with on a virtual image stack (c. 3000×2500×5500 16-bit pixels, 82.5 GB)

java.lang.IndexOutOfBoundsException
	ij.ImageStack.getVoxel(ImageStack.java:381)
	ij.process.StackProcessor.getNeighborhood(StackProcessor.java:358)
	ij.process.StackProcessor.filter3D(StackProcessor.java:292)
	ij.plugin.Filters3D$1.run(Filters3D.java:109)

	at ij.ImageStack.getVoxel(ImageStack.java:381)
	at ij.process.StackProcessor.getNeighborhood(StackProcessor.java:358)
	at ij.process.StackProcessor.filter3D(StackProcessor.java:292)
	at ij.plugin.Filters3D$1.run(Filters3D.java:109)

Intuitively I expect that an empty array is created in RAM with the same dimensions as the input image, and then for each pixel of the output image the kernel is collected from the input image and the median pixel value in the kernel is written to RAM. Once all the pixel coordinates have been visited, the output image stack should be displayed as an ordinary (not virtual) stack. It is a bit slow to do this on a virtual stack, but it’s huge and I don’t yet have enough RAM to store input and output images at the same time. I have tested kernels of radius 1, 2, 3 and 6 pixels, all of which cause the same exception to be thrown.

@ThomasBoudier is this something you know about?

Hi @mdoube,

Actually I never tried 3D Filters in virtual mode, the implementation in ImageJ and my 3DFastFilters are slightly different. In ImageJ the filter will ultimately will want to access a voxel via getVoxel and I think this is not compatible with virtual stack (yet). Interestingly with my 3DFastFilters there is no error in virtual mode but it seems the whole stack is read into memory before filtering, so not compatible with virtual mode.

I guess the temporary solution would be to :

  • Load slices from z-radiusz to z+radisuz into memory
  • Do the 3D Processing for slice z
  • Save slice z

If I have time, I will look into virtual mode for my plugins. I guess imglib2 should be able to handle virtual mode.

Best,

Thomas

2 Likes

Thanks @ThomasBoudier - guess I should hang on until my new sticks of RAM arrive…