Error using FFT:java.lang.ArrayIndexOutOfBoundsException: 65535


#1

I load TIF using Bio Format plugin in FIJI (I tried Bio7 too) and when I try to use FFT in the image, the following error is displayed:
I did the same process with other similar images and had no problems.

Error:

"> ImageJ 1.51t16; Java 1.8.0_152 [64-bit]; Windows 10 10.0; 3162MB of 20260MB (15%)

java.lang.ArrayIndexOutOfBoundsException: 65535
at ij.process.ByteProcessor.applyTable(ByteProcessor.java:484)
at ij.process.ImageProcessor.process(ImageProcessor.java:983)
at ij.process.ImageProcessor.fill(ImageProcessor.java:1559)
at ij.plugin.FFT.pad(FFT.java:184)
at ij.plugin.FFT.newFHT(FFT.java:157)
at ij.plugin.FFT.run(FFT.java:76)
at ij.IJ.runPlugIn(IJ.java:199)
at ij.Executer.runCommand(Executer.java:137)
at ij.Executer.run(Executer.java:66)
at java.lang.Thread.run(Unknown Source)"

The image info:

"BitsPerPixel = 8
DimensionOrder = XYCZT
IsInterleaved = false
IsRGB = false
LittleEndian = true
PixelType = uint8
Series 0 Name = file.tif
SizeC = 1
SizeT = 1
SizeX = 33677
SizeY = 17904
SizeZ = 1
BitsPerSample = 8
Compression = Uncompressed
ImageLength = 17904
ImageWidth = 33677
Location = C:\file.tif
MetaDataPhotometricInterpretation = Monochrome
MetaMorph = no
NumberOfChannels = 1
PhotometricInterpretation = BlackIsZero
PlanarConfiguration = Chunky
SampleFormat = unsigned integer
SamplesPerPixel = 1


ImageJ 1.51t16; Java 1.8.0_152 [64-bit]; Windows 10 10.0; 3223MB of 20260MB (15%)

Title: image.tif
Width: 33677 pixels
Height: 17904 pixels
Size: 575MB
Pixel size: 1x1 pixel^2
ID: -2
Bits per pixel: 8 (grayscale LUT)
Display range: 0-255
No threshold
Magnification: 0.03
ScaleToFit: false
Uncalibrated
Path: C:\file.tif.tif
Screen location: 0,0 (1920x1080)
No overlay
No selection"


#2

Hi,

I think that this image is very large.
If you can resize the image, please scale down less than 32768(width or height).
In the fft conversion, it convert the image size to a power of 2 to speed up the calculation.
The image width is 33677, so fft method converts this image to a large image(65536 x 65536)
Since it is the maximum pixel size, I think that the size of the image is an error because this is the limit.

That said, but with this size out-of-memory error has come out in my environment…

hwada


#3

Unfortunately @hwada is right, you are going to have to think about partitioning your data.

Perhaps produce a bunch of small regions across your image and get the FFT for it and pool your results together.

Here is a macro that creates boxes of a defined size based on a quick and dirty segmentation of the image.
You could then iterate through each box, get the FFT and then perform your favorite measurements

//@Integer (label="Size (power of 2)", value=512) box_size
//@Integer (label="Offset", value=10) offset

/*
 * Make boxes inside an object
 * Simple tool to generate an array of boxes from a fluorescent object.
 * 
 * Olivier Burri, EPFL - SV - BIOP 
 * 
 */
original = getTitle();
getDimensions(w,h,c,z,t);
roiManager("reset");

run("Duplicate...", "title=blur");
run("Gaussian Blur...", "sigma=4");
setAutoThreshold("Triangle dark");

setOption("BlackBackground", true);
run("Convert to Mask");
run("Fill Holes");
run("Create Selection");
roiManager("Add");
close();
main_roi_idx = roiManager("count") - 1;
for(x=0;x<w;x+=box_size+offset) {
	for(y=0;y<h;y+=box_size+offset) {
		roiManager("Select", main_roi_idx);
		if(isInside(x,y, box_size)) {
			makeRectangle(x,y,box_size, box_size);
			roiManager("Add");
		}
	}
}

function isInside(x,y, box_size) {
	is_it1 = Roi.contains(x, y);
	is_it2 = Roi.contains(x+box_size, y);
	is_it3 = Roi.contains(x, y+box_size);
	is_it4 = Roi.contains(x+box_size, y+box_size);
	so_does_it = (is_it1 && is_it2 && is_it3 && is_it4);
	return so_does_it;
}

Based on your image


#4

Many thanks for the explanation @oburri @hwada !I’m going to test the macro.