TrakEM2 : segmentation with polygon ROI not working (Bug)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

TrakEM2 : segmentation with polygon ROI not working (Bug)

bpavie
Dear All,

I watched the following video http://www.ini.uzh.ch/~acardona/movies/arealist-create-and-edit.mp4 describing how to segment in TrakEM2 and at 43 sec, it demonstrates how to use polygon ROI tool to draw a ROI then use the FIT SPLINE option to get a perfect selection.
Unfortunately, using the last FIJI version available (ImageJ 1.49t), it impossible to use the polygon ROI tool which is not working anymore. Using it will just draw a tiny yellow square as a first point and refuse to add a new one, getting stuck. You can't even unselect the ROI easily.
I am not sure if it is due to an update of the plugin or of ImageJ.
The tool is working fine outside of TrakEM2.

Does anyone has a different experience or know how to solve this issue?

Benjamin
Reply | Threaded
Open this post in threaded view
|

Re: TrakEM2 : segmentation with polygon ROI not working (Bug)

Albert Cardona-2
Dear Benjamin,

Very likely the ImageJ API changed and TrakEM2 was not adjusted to deal
with the change.

The issue is likely related to the mousePressed/mouseDragged/mouseReleased
functions of the ij.ImageCanvas, which the
ini.trakem2.display.DisplayCanvas implements:

https://github.com/trakem2/TrakEM2/blob/master/TrakEM2_/src/main/java/ini/trakem2/display/DisplayCanvas.java#L574

If you'd like to have a look and provide a patch I'd be glad to apply it.

Thanks,

Albert

2015-06-11 9:04 GMT-04:00 bpavie <[hidden email]>:

> Dear All,
>
> I watched the following video
> http://www.ini.uzh.ch/~acardona/movies/arealist-create-and-edit.mp4
> describing how to segment in TrakEM2 and at 43 sec, it demonstrates how to
> use polygon ROI tool to draw a ROI then use the FIT SPLINE option to get a
> perfect selection.
> Unfortunately, using the last FIJI version available (ImageJ 1.49t), it
> impossible to use the polygon ROI tool which is not working anymore. Using
> it will just draw a tiny yellow square as a first point and refuse to add a
> new one, getting stuck. You can't even unselect the ROI easily.
> I am not sure if it is due to an update of the plugin or of ImageJ.
> The tool is working fine outside of TrakEM2.
>
> Does anyone has a different experience or know how to solve this issue?
>
> Benjamin
>
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/TrakEM2-segmentation-with-polygon-ROI-not-working-Bug-tp5013118.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
http://albert.rierol.net
http://www.janelia.org/lab/cardona-lab
http://www.ini.uzh.ch/~acardona/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: TrakEM2 : segmentation with polygon ROI not working (Bug)

Rasband, Wayne (NIH/NIMH) [E]
In reply to this post by bpavie
> On Jun 11, 2015, at 9:04 AM, bpavie <[hidden email]> wrote:
>
> Dear All,
>
> I watched the following video
> http://www.ini.uzh.ch/~acardona/movies/arealist-create-and-edit.mp4
> describing how to segment in TrakEM2 and at 43 sec, it demonstrates how to
> use polygon ROI tool to draw a ROI then use the FIT SPLINE option to get a
> perfect selection.
> Unfortunately, using the last FIJI version available (ImageJ 1.49t), it
> impossible to use the polygon ROI tool which is not working anymore. Using
> it will just draw a tiny yellow square as a first point and refuse to add a
> new one, getting stuck. You can't even unselect the ROI easily.
> I am not sure if it is due to an update of the plugin or of ImageJ.
> The tool is working fine outside of TrakEM2.

You can test to see if this problem is due to an ImageJ 1.49t regression by downgrading to 1.49s. Do this by using the Help>Update ImageJ command and selecting “previous” from the drop down menu.

-wayne


> Does anyone has a different experience or know how to solve this issue?
>
> Benjamin
>
>
> --
> View this message in context: http://imagej.1557.x6.nabble.com/TrakEM2-segmentation-with-polygon-ROI-not-working-Bug-tp5013118.html
> Sent from the ImageJ mailing list archive at Nabble.com.



--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Croping images with border equal to zero

CARL Philippe (LBP)
Dear all,
I have some issues with selecting and cropping a part of my images.
The pictures I have look like the following ones:
run("Blobs (25K)");
run("Canvas Size...", "width=276 height=274 position=Center zero");
or
run("Blobs (25K)");
run("Canvas Size...", "width=276 height=274 position=Top-Right zero");
i.e. 8bit pictures with a border equal to zero and this border can be everywhere.
Which means all around the picture, or only on a side or at the top-left, top-right,… side…
And what I woulk like to do is to crop out the border part of the picture (which has always an intensity equal to zero).
So what would be the most efficient way for performing this?
I tried something similar to:
run("Blobs (25K)");
run("Canvas Size...", "width=276 height=274 position=Center zero");
doWand(5, 269);
but the obtained result for the doWand(5, 269); or doWand(5, 137); is quite different which is kind of problematic.
Also sometimes I need to make an inverse in order to perform this like:
run("Blobs (25K)");
run("Canvas Size...", "width=276 height=274 position=Top-Right zero");
doWand(6, 209);
run("Make Inverse");
I thank you very much in advance for your help and ideas.
My best regards,
Philippe

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Croping images with border equal to zero

Gabriel Landini
On Thursday 11 Jun 2015 17:06:50 CARL Philippe wrote:
> I have some issues with selecting and cropping a part of my images.
> The pictures I have look like the following ones:
> run("Blobs (25K)");
> run("Canvas Size...", "width=276 height=274 position=Center zero");

Hi,
There is an auto crop plugin in Fiji.
Alternatively you could write a macro that just scans the image borders by
rows and columns, going towards the centre and stops when a row or column has
non-zero pixels. Then use those coordinates to define a rectangular region and
then use the Crop command.

Cheers

Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Croping images with border equal to zero

Krs5
I am not totally sure what you want to select but this code will crop an area including the white border.

run("Blobs (25K)");
//run("Canvas Size...", "width=276 height=274 position=Center zero");
//run("Threshold...");
makeRectangle(54, 46, 118, 122);
run("Make Band...", "band=5");
setForegroundColor(255, 255, 255);
run("Fill", "slice");
setThreshold(0, 0);
setOption("BlackBackground", false);
run("Analyze Particles...", "add");
roiManager("Select", 0);
run("Crop");

Best wishes

Kees

-----Original Message-----
From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Gabriel Landini
Sent: 11 June 2015 16:33
To: [hidden email]
Subject: Re: Croping images with border equal to zero

On Thursday 11 Jun 2015 17:06:50 CARL Philippe wrote:
> I have some issues with selecting and cropping a part of my images.
> The pictures I have look like the following ones:
> run("Blobs (25K)");
> run("Canvas Size...", "width=276 height=274 position=Center zero");

Hi,
There is an auto crop plugin in Fiji.
Alternatively you could write a macro that just scans the image borders by rows and columns, going towards the centre and stops when a row or column has non-zero pixels. Then use those coordinates to define a rectangular region and then use the Crop command.

Cheers

Gabriel

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: TrakEM2 : segmentation with polygon ROI not working (Bug)

bpavie
In reply to this post by Albert Cardona-2
Dear Albert,

According to Wayne Rasband who tested TrakEM2 in ImageJ 1.49s, 1.48, 1.47 and 1.46, it did not work in any of these earlier versions (I add this comment for the forum):

The problem with the polygon ROI tool in TrakEM2 does not seem to be due to an ImageJ API change in the last three years. I tried using the tool in ImageJ 1.49s, 1.48, 1.47 and 1.46 and it did not work in any of these earlier versions..

Best regards,

-wayne


So it may come from an earlier version of ImageJ of a regression in the TrakEM2 plugin (but I do not see any history of the class https://github.com/trakem2/TrakEM2/blob/master/TrakEM2_/src/main/java/ini/trakem2/display/DisplayCanvas.java#L574 on github.

I will be happy to test on previous ImageJ version but I do not know how to install TrakEM2 on ImageJ without to use Fiji. It will be easier to test it on different ImageJ version than with Fiji, which to my knowledge do not offer to revert ImageJ version.

Best,
Benjamin

Dear Benjamin,

Very likely the ImageJ API changed and TrakEM2 was not adjusted to deal
with the change.

The issue is likely related to the mousePressed/mouseDragged/mouseReleased
functions of the ij.ImageCanvas, which the
ini.trakem2.display.DisplayCanvas implements:

https://github.com/trakem2/TrakEM2/blob/master/TrakEM2_/src/main/java/ini/trakem2/display/DisplayCanvas.java#L574

If you'd like to have a look and provide a patch I'd be glad to apply it.

Thanks,

Albert

2015-06-11 9:04 GMT-04:00 bpavie <[hidden email]>:

> Dear All,
>
> I watched the following video
> http://www.ini.uzh.ch/~acardona/movies/arealist-create-and-edit.mp4
> describing how to segment in TrakEM2 and at 43 sec, it demonstrates how to
> use polygon ROI tool to draw a ROI then use the FIT SPLINE option to get a
> perfect selection.
> Unfortunately, using the last FIJI version available (ImageJ 1.49t), it
> impossible to use the polygon ROI tool which is not working anymore. Using
> it will just draw a tiny yellow square as a first point and refuse to add a
> new one, getting stuck. You can't even unselect the ROI easily.
> I am not sure if it is due to an update of the plugin or of ImageJ.
> The tool is working fine outside of TrakEM2.
>
> Does anyone has a different experience or know how to solve this issue?
>
> Benjamin
>
>
>
>
> --
> View this message in context:
> http://imagej.1557.x6.nabble.com/TrakEM2-segmentation-with-polygon-ROI-not-working-Bug-tp5013118.html
> Sent from the ImageJ mailing list archive at Nabble.com.
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>



--
http://albert.rierol.net
http://www.janelia.org/lab/cardona-lab
http://www.ini.uzh.ch/~acardona/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html

Reply | Threaded
Open this post in threaded view
|

Re: TrakEM2 : segmentation with polygon ROI not working (Bug)

bpavie
Dear,

After a quick look of ImageJ source code of the ImageCanvas from ImageJ and the DisplayCanvas of TrakEM2 plugin, it looks the problem is more coming from the mouseMoved() method, which in DisplayCanvas doesn't look to manage the tools Toolbar.POLYGON, Toolbar.POLYLINE, Toolbar.ANGLE.

It looks at some point DisplayCanvas  was taking care of them which will explain why the video is working with using the Toolbar.POLYGON tool, but know none of the above tools are doing anything.
Actually, it looks it was using something similar to ImageCanvas and that it was commented and replaced by a threaded based class (see https://github.com/trakem2/TrakEM2/blob/master/TrakEM2_/src/main/java/ini/trakem2/display/DisplayCanvas.java#L1317 and https://github.com/trakem2/TrakEM2/blob/master/TrakEM2_/src/main/java/ini/trakem2/display/DisplayCanvas.java#L1373) which doesn't handle the above tools.

I am not sure how to change that easily, since I do not know why the default method has been replaced by the MouseMovedThread class for the mouse moved event (you must have a good reason).

Best,
Benjamin