Re: fiji shape index map plugin

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

Re: fiji shape index map plugin

dscho
Hi Yanbin,

On Tue, 10 Jun 2014, Yanbin Lu wrote:

> I'm a graduate student in University of Houston, I have a quick question
> regarding the  fiji shape index map plugin:

I am Cc:ing the ImageJ mailing list because it is really the best place to
ask questions about ImageJ plugins, and others on that list might have
valuable input and/or time to help, too.

> In the fiji script, it is calculated as:
>
>                                         dnx_x + dny_y
>         s = 2 / PI * arctan ---------------------------------------
>                              sqrt((dnx_x - dny_y)^2 + 4 dny_x dnx_y)
>
> double D = Math.sqrt((dnx_x - dny_y) * (dnx_x - dny_y) + 4 * dnx_y * dny_x)
>
>
> But I came across to a problem where (dnx_x - dny_y) * (dnx_x - dny_y) + 4
> * dnx_y * dny_x is negative. Just wonderiing how did you handle this?

That should never happen. I can only imagine that it is a problem of
precision: the derivatives are calculated in 32-bit floats because that is
the most precise floating point data type ImageJ 1.x can handle, and the
32-bit floats in Java have only 23 bits in their mantissa.

You could build the plugin from source (it is maintained in the Git
repository at https://github.com/fiji/Fiji_Plugins, in the subdirectory
src/main/java/fiji/geom/Shape_Index_Map.java) and put in a check where the
operand of the square root is negative, printing the values involved at
that point. If my hypothesis is true, the negative value should be very
small compared to the individual summands.

In that case, I would expect the nominator to be substantially different
from zero so that the arctan essentially becomes PI / 2 or -PI / 2,
depending on the sign of the nominator.

Hopefully you can figure it out with these considerations in mind,
Johannes

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