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

Error when applying opening/closing with an ellipsoid structuring element #82

Open
giocard opened this issue Feb 6, 2024 · 4 comments
Assignees

Comments

@giocard
Copy link

giocard commented Feb 6, 2024

Note: the error appears only when specifying the Ball element and for some combinations of radii (e.g. 4,4,1 or 8,8,2)
I suspect that this is due to some rounding error when adding and removing the borders, but I was not able to pinpoint the piece of code.

The error can be reproduced with these two macro commands

newImage("HyperStack", "8-bit grayscale-mode", 512, 512, 1, 32, 1);
run("Morphological Filters (3D)", "operation=Opening element=Ball x-radius=4 y-radius=4 z-radius=1");

The error message is

(Fiji Is Just) ImageJ 2.14.0/1.54f; Java 1.8.0_322 [64-bit]; Windows 10 10.0; 858MB of 65386MB (1%)

java.lang.IllegalArgumentException: Crop bounds exceed image bounds
at inra.ijpb.shape.ImageShape.cropRect(ImageShape.java:208)
at inra.ijpb.morphology.strel.AbstractStrel3D.closing(AbstractStrel3D.java:341)
at inra.ijpb.morphology.filter.Closing.process(Closing.java:82)
at inra.ijpb.morphology.Morphology.closing(Morphology.java:507)
at inra.ijpb.morphology.Morphology$Operation.apply(Morphology.java:176)
at inra.ijpb.plugins.MorphologicalFilter3DPlugin.process(MorphologicalFilter3DPlugin.java:169)
at inra.ijpb.plugins.MorphologicalFilter3DPlugin.run(MorphologicalFilter3DPlugin.java:110)
at ij.IJ.runUserPlugIn(IJ.java:244)
at ij.IJ.runPlugIn(IJ.java:210)
at ij.Executer.runCommand(Executer.java:152)
at ij.Executer.run(Executer.java:67)
at ij.IJ.run(IJ.java:326)
at ij.IJ.run(IJ.java:337)
at ij.macro.Functions.doRun(Functions.java:703)
at ij.macro.Functions.doFunction(Functions.java:99)
at ij.macro.Interpreter.doStatement(Interpreter.java:281)
at ij.macro.Interpreter.doStatements(Interpreter.java:267)
at ij.macro.Interpreter.run(Interpreter.java:163)
at ij.macro.Interpreter.run(Interpreter.java:93)
at ij.macro.Interpreter.run(Interpreter.java:107)
at ij.plugin.Macro_Runner.runMacro(Macro_Runner.java:164)
at ij.IJ.runMacro(IJ.java:165)
at ij.IJ.runMacro(IJ.java:154)
at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1186)
at net.imagej.legacy.IJ1Helper$3.call(IJ1Helper.java:1182)
at net.imagej.legacy.IJ1Helper.runMacroFriendly(IJ1Helper.java:1133)
at net.imagej.legacy.IJ1Helper.runMacro(IJ1Helper.java:1182)
at net.imagej.legacy.plugin.IJ1MacroEngine.eval(IJ1MacroEngine.java:145)
at org.scijava.script.ScriptModule.run(ScriptModule.java:173)
at org.scijava.module.ModuleRunner.run(ModuleRunner.java:165)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:125)
at org.scijava.module.ModuleRunner.call(ModuleRunner.java:64)
at org.scijava.thread.DefaultThreadService.lambda$wrap$2(DefaultThreadService.java:247)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:750)

@dlegland
Copy link
Contributor

dlegland commented Feb 6, 2024

Hi,

thanks for reporting!

It looks like a rounding error indeed! Actually, I could not reproduce, but I'm pretty sure the problem simply comes from the control that throws the exception. I try to check this more in details soon!

@dlegland dlegland self-assigned this Feb 6, 2024
@giocard
Copy link
Author

giocard commented Feb 6, 2024

Hi,

thank you for looking into it. If it is of any help, I tried on two different Windows machine and on a fresh installation of Fiji, and I always get the error.
I also tried previous versions of the plugin, and the error is present in 1.6.0 but not in 1.5.0 (as packaged in sites.imagej.net)

@dlegland
Copy link
Contributor

dlegland commented Feb 7, 2024

Hi,

I found a mistake in the way the "offset" of the structuring element was computed. I fixed it in 355b6c8, this made the bug disappear for me (I could finally reproduce on another computer).

@giocard
Copy link
Author

giocard commented Feb 7, 2024

Great! Thank you very much.

@giocard giocard changed the title Error when applying opening/closing with an ellipsoid strcutring element Error when applying opening/closing with an ellipsoid structuring element Mar 12, 2024
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

2 participants