Error using FFT:java.lang.ArrayIndexOutOfBoundsException: 65535



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.


"> 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(
at ij.process.ImageProcessor.process(
at ij.process.ImageProcessor.fill(
at ij.plugin.FFT.pad(
at ij.plugin.FFT.newFHT(
at ij.IJ.runPlugIn(
at ij.Executer.runCommand(
at 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
Path: C:\file.tif.tif
Screen location: 0,0 (1920x1080)
No overlay
No selection"



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…



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();

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");
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);

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


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