Posted by
Rasband, Wayne (NIH/NIMH) [E] on
Jun 12, 2014; 5:18pm
URL: http://imagej.273.s1.nabble.com/Overlaying-ROIs-very-costly-tp5008136p5008174.html
On Jun 11, 2014, at 11:37 AM, Burri Olivier wrote:
> Hi all,
>
> Just curious if anyone else is experiencing very slow response time from the image window when there is an overlay.
>
> I have an RGB Image with two overlays corresponding to segmentations in different channels. The image is 2500x1800px.
> Overlays are 2px thick and of different colors
>
> Any attempt to zoom in or pan on the image is extremely slow (seconds or 10s of seconds).
>
> You can find the image being troublesome here:
>
https://dl.dropboxusercontent.com/u/86578924/overlayProblem.tif (18Mb, RGB)
>
> This happened running Fiji under Win7 x64, Corei7 3.4GHz with 24Gb RAM
The very slow response times are the result of setting the stroke width to 2. To fix this problem, open the troublesome image and run this JavaScript:
imp = IJ.getImage();
imp.deleteRoi();
overlay = imp.getOverlay();
for (i=0; i<overlay.size(); i++)
overlay.get(i).setStrokeWidth(0);
It sets the stroke width of the two selections in the overlay to 0. It also removes the ROI included with the image, which also has a stroke width of 2. A stroke width of zero (the default) causes ROI and overlay outlines to always be drawn at a width of 1, regardless of the magnification.
I do not understand why it takes so long to draw outlines with a stroke width greater than 1. The slowdown is deep in Java2D. I get stack traces like the one below when I run ImageJ from the command line and type control+\ while waiting for the overlay to be drawn.
-wayne
"AWT-EventQueue-0" prio=6 tid=102943800 nid=0x11e7e1000 runnable [11e7de000]
[java] java.lang.Thread.State: RUNNABLE
[java] at sun.dc.pr.PathStroker.beginSubpath(Native Method)
[java] at sun.java2d.pipe.DuctusRenderer.feedConsumer(DuctusRenderer.java:246)
[java] at sun.java2d.pipe.LoopPipe.getStrokeSpans(LoopPipe.java:272)
[java] at sun.java2d.pipe.LoopPipe.draw(LoopPipe.java:182)
[java] at sun.java2d.pipe.PixelToParallelogramConverter.draw(PixelToParallelogramConverter.java:130)
[java] at sun.java2d.pipe.ValidatePipe.draw(ValidatePipe.java:136)
[java] at sun.java2d.SunGraphics2D.draw(SunGraphics2D.java:2630)
[java] at ij.gui.ShapeRoi.draw(ShapeRoi.java:1024)
[java] at ij.gui.Roi.drawOverlay(Roi.java:981)
[java] at ij.gui.ImageCanvas.drawRoi(ImageCanvas.java:337)
[java] at ij.gui.ImageCanvas.drawOverlay(ImageCanvas.java:288)
[java] at ij.gui.ImageCanvas.paint(ImageCanvas.java:176)
[java] at ij.gui.ImageCanvas.update(ImageCanvas.java:151)
--
ImageJ mailing list:
http://imagej.nih.gov/ij/list.html