Skip to content

Conversation

@axtimwalde
Copy link
Member

Does that fix #212 ?

@ctrueden
Copy link
Member

ctrueden commented Jun 7, 2018

Without this patch, the following Groovy script works in my up-to-date version of Fiji (with imglib2 5.3.0):

#@ ImageJ ij

import net.imagej.Dataset
import net.imagej.ImageJ
import net.imglib2.interpolation.randomaccess.LanczosInterpolatorFactory

image = ij.scifio().datasetIO().open("/Users/curtis/data/clown.jpg")
ij.ui().show(image)

interp = new LanczosInterpolatorFactory()

double[] scaleDown = [0.5, 0.5, 1]
Object small = ij.op().run("scaleView", image, scaleDown, interp)
ij.ui().show(small)

double[] scaleUp = [2.5, 2.5, 1]
Object large = ij.op().run("scaleView", image, scaleUp, interp)
ij.ui().show(large)

double[] scaleWeird = [2.2, 0.6, 1]
Object stretched = ij.op().run("scaleView", image, scaleWeird, interp)
ij.ui().show(stretched)

And with the patch, it also works.

@tpietzsch
Copy link
Member

Maybe the difference is that clown.jpg is not FloatType?

@ctrueden
Copy link
Member

ctrueden commented Jun 9, 2018

This script also works:

#@ ImageJ ij

import net.imagej.Dataset
import net.imagej.ImageJ
import net.imglib2.interpolation.randomaccess.LanczosInterpolatorFactory

image = ij.scifio().datasetIO().open("/Users/curtis/data/clown.jpg")
image32 = ij.op().convert().float32(image)
ij.ui().show(image32)

interp = new LanczosInterpolatorFactory()

double[] scaleDown = [0.5, 0.5, 1]
Object small = ij.op().run("scaleView", image32, scaleDown, interp)
ij.ui().show(small)

double[] scaleUp = [2.5, 2.5, 1]
Object large = ij.op().run("scaleView", image32, scaleUp, interp)
ij.ui().show(large)

double[] scaleWeird = [2.2, 0.6, 1]
Object stretched = ij.op().run("scaleView", image32, scaleWeird, interp)
ij.ui().show(stretched)

@ctrueden
Copy link
Member

ctrueden commented Oct 12, 2018

I rebased the lanczos-range branch over the latest master branch, and tested it with a generalized version of @tpietzsch's original non-working code from #212. Here is the code I used:

final float[] f = {10, 20, 30, 40, 50, 60, 70, 80, 90, 100};
final Img<FloatType> img = ArrayImgs.floats(f, f.length);
final RealRandomAccess<FloatType> a = Views.interpolate(Views.extendBorder(
	img), new LanczosInterpolatorFactory<>()).realRandomAccess();
for (int i=0; i<img.dimension(0); i++) {
	a.setPosition(new int[] { i });
	System.out.println(a.get());
	a.setPosition(new float[] { i + 0.5f });
	System.out.println(a.get());
}

I found that changing + 2 to + 3 for the lookup table array was insufficient to fix the problem. Empirically, for 1D data ranging in length between 4 elements and 20 elements, the minimum value that fixes the exception is + 22. Anything less than that still fails.

@axtimwalde Does that shed any light on the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LanczosInterpolator crashes

4 participants