NOTICE! This is a static HTML version of a legacy ImageJ Trac ticket.

The ImageJ project now uses GitHub Issues for issue tracking.

Please file all new issues there.

Ticket #1986 (closed defect: fixed)

Opened 2013-08-19T11:53:36-05:00

Last modified 2013-08-19T14:28:53-05:00

Crop can throw an exception

Reported by: bdezonia Owned by: bdezonia
Priority: major Milestone: imagej2-b8-analysis
Component: Display API Version:
Severity: serious Keywords:
Cc: Blocked By:
Blocking: #1457

Description

Open any image and run the crop command. Sometimes (and usually for images > 2d) an exception is thrown. Note that if you draw an overlay in the view afterwards the window is redrawn and you can see crop worked. The exception message is of the form "expected X converters but got Y" where X and Y vary (even being different between different runs of crop on the a fresh copy of the same image).

java.lang.IllegalArgumentException: Expected 1 converters but got 2

at net.imglib2.display.CompositeXYProjector.<init>(CompositeXYProjector.java:93)
at imagej.data.display.DefaultDatasetView.initializeView(DefaultDatasetView.java:514)
at imagej.data.display.DefaultDatasetView.rebuild(DefaultDatasetView.java:382)
at imagej.data.display.DefaultImageDisplay.rebuild(DefaultImageDisplay.java:136)
at imagej.data.display.DefaultImageDisplay.display(DefaultImageDisplay.java:270)
at imagej.data.display.DefaultOverlayService.addOverlays(DefaultOverlayService.java:149)
at imagej.core.commands.imglib.CropImage.run(CropImage.java:158)
at imagej.command.CommandModule.run(CommandModule.java:196)
at imagej.module.ModuleRunner.run(ModuleRunner.java:168)
at imagej.module.ModuleRunner.call(ModuleRunner.java:129)
at imagej.module.ModuleRunner.call(ModuleRunner.java:1)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
at java.lang.Thread.run(Thread.java:680)

Change History

comment:1 Changed 2013-08-19T14:14:51-05:00 by bdezonia

The last two lines of CropImage::run() are:

dataset.setImgPlus(croppedData);

here the duplicated and origin translated overlays are attached
overlayService.addOverlays(display, newOverlays);

The first line does a rebuild. And the second line does a rebuild once for each overlay being copied. Thus in this case you have multiple simultaneous rebuilds taking place that are messing with the same list of lut converters. Race conditions cause things to behave erratically.

One thing I can do is make some method synchronized that will fix this issue.

Another approach is to see how to avoid these multiple rebuilds. This used to work. I think the event processing was changed recently and something that used to queue serially now queues simultaneously.

comment:2 Changed 2013-08-19T14:28:53-05:00 by bdezonia

  • Status changed from new to closed
  • Resolution set to fixed

Took synchronized approach in DefaultDatasetView. Fixed with commit e51a46610a61a99721673bc18c5badfefce6c7d3