Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SobelRAI derivativeComputer array error prone if dimension mismatch #627

Open
gselzer opened this issue Jun 8, 2020 · 5 comments
Open

Comments

@gselzer
Copy link
Contributor

gselzer commented Jun 8, 2020

As I discovered by trying to solve a post on forum.image.sc, SobelRAI can throw ArrayIndexOutOfBoundsExceptions if the input image differs on the number of dimensions from what was passed to the matcher during the creation of the Op. The faulty line is here: if the input image has fewer dimensions than the image passed during creation, we will receive an ArrayIndexOutOfBoundsException in that for loop, and if we have more dimensions than we had during Op creation, then not all dimensions of the image will be processed.

Is there any reason that we do not run a for loop on all dimensions of the image and use only one derivativeComputer? We could just transform the dimensions of the image to compute every dimension...

@imagesc-bot
Copy link

This issue has been mentioned on Image.sc Forum. There might be relevant details there:

https://forum.image.sc/t/slice-wise-sobel-using-ops/38720/2

@ctr26
Copy link

ctr26 commented Jun 8, 2020

I think Gauss and derivative Gauss also have the same behaviour btw.

@gselzer
Copy link
Contributor Author

gselzer commented Jun 8, 2020

@ctr26 can you be more specific in which Ops have the issue?

I am only seeing this issue in PartialDerivativesRAI. I am not seeing this issue in any of the Gauss ops

@ctr26
Copy link

ctr26 commented Jun 8, 2020

This fails for me:

#@ Dataset data
#@OUTPUT Dataset output
#@ OpService ops
#@ DatasetService ds

from net.imagej.axis import Axes
converted = ops.convert().float32(data.getImgPlus())

dog = ops.create().img(converted)

converted_in = ops.transform().flatIterableView(converted)
converted_out = ops.transform().flatIterableView(dog)

#dog_op = ops.op("filter.dog", converted_in,1,1)
#dog_op = ops.op("filter.sobel", converted_in)
dog_op = ops.op("filter.derivativeGauss", converted_in,1,1)

t_dim = data.dimensionIndex(Axes.TIME)
fixed_axis = [d for d in range(0, data.numDimensions()) if d != t_dim]

ops.slice(converted_out,converted_in, dog_op, fixed_axis)

output = ds.create(converted_out)
print("success")

@gselzer
Copy link
Contributor Author

gselzer commented Jun 8, 2020

@ctr26 that is failing for other reasons. Check the agreement of the arguments you are passing with the parameters of the Op (forum.image.sc is the place to discuss this). If you find any Ops that are experiencing the same issue that we are seeing with SobelRAI and PartialDerivativesRAI (within this code base), this would be the place to report it.

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

No branches or pull requests

3 participants