Maximum Region Size for Distance Map limited by Map being 8 bit

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

Maximum Region Size for Distance Map limited by Map being 8 bit

Michael P Ellis
Dear IMageJ group,

I am writing a macro that attempts to create the largest circular region of interest that can be contained within the current region of interest. I am using the Distance Map function but have hit a limitation in that the Distance Map created is an 8 bit image and therefore the maximum distance that can be stored in the map is 255.

This can be shown with the script below. Since the original region is a circle (radius 350), the distance map ought to be a radial gradient going from  0 at the edge to a maximum value of 350 at the centre of the circle, however the since actual result is capped to an unsigned 8 bit quantity, there is a large flat circular area that is uniformly 255.

Any suggestions?

Is it possible to specify that the distance map be 16 bit?

newImage("Test", "8-bit White", 800, 800, 1);
run("Specify...", "width=700 height=700 x=400 y=400 oval centered");
run("Clear Outside");
run("Fill", "slice");
run("Select All");
run("Distance Map");

Thanks in advance for any suggestions.

Michael Ellis
www.dsuk.biz
Reply | Threaded
Open this post in threaded view
|

Re: Maximum Region Size for Distance Map limited by Map being 8 bit

Michael Schmid
Hi Michael,

in Process>Binary>Options you can set the distance map (EDM) to 16 or 32 bits (float).
By the way, you have to make sure that you set whether you have a black background or not (also in Process>Binary>Options); otherwise your short macro may create the distance map outside the circle.

Don't be astonished if the distance map maximum of your circle is not exactly 350 but 349.3 or so; that's because of the rough borders due to pixel quantization.

Michael
________________________________________________________________
On Feb 3, 2012, at 17:15, Michael Ellis wrote:

> Dear IMageJ group,
>
> I am writing a macro that attempts to create the largest circular region of interest that can be contained within the current region of interest. I am using the Distance Map function but have hit a limitation in that the Distance Map created is an 8 bit image and therefore the maximum distance that can be stored in the map is 255.
>
> This can be shown with the script below. Since the original region is a circle (radius 350), the distance map ought to be a radial gradient going from  0 at the edge to a maximum value of 350 at the centre of the circle, however the since actual result is capped to an unsigned 8 bit quantity, there is a large flat circular area that is uniformly 255.
>
> Any suggestions?
>
> Is it possible to specify that the distance map be 16 bit?
>
> newImage("Test", "8-bit White", 800, 800, 1);
> run("Specify...", "width=700 height=700 x=400 y=400 oval centered");
> run("Clear Outside");
> run("Fill", "slice");
> run("Select All");
> run("Distance Map");
>
> Thanks in advance for any suggestions.
>
> Michael Ellis
> www.dsuk.biz
Reply | Threaded
Open this post in threaded view
|

Re: Maximum Region Size for Distance Map limited by Map being 8 bit

Michael P Ellis
Michael, thanks!

Perfect!

Regards -- Michael Ellis

On 3 Feb 2012, at 16:34, Michael Schmid wrote:

> Hi Michael,
>
> in Process>Binary>Options you can set the distance map (EDM) to 16 or 32 bits (float).
> By the way, you have to make sure that you set whether you have a black background or not (also in Process>Binary>Options); otherwise your short macro may create the distance map outside the circle.
>
> Don't be astonished if the distance map maximum of your circle is not exactly 350 but 349.3 or so; that's because of the rough borders due to pixel quantization.
>
> Michael
> ________________________________________________________________
> On Feb 3, 2012, at 17:15, Michael Ellis wrote:
>
>> Dear IMageJ group,
>>
>> I am writing a macro that attempts to create the largest circular region of interest that can be contained within the current region of interest. I am using the Distance Map function but have hit a limitation in that the Distance Map created is an 8 bit image and therefore the maximum distance that can be stored in the map is 255.
>>
>> This can be shown with the script below. Since the original region is a circle (radius 350), the distance map ought to be a radial gradient going from  0 at the edge to a maximum value of 350 at the centre of the circle, however the since actual result is capped to an unsigned 8 bit quantity, there is a large flat circular area that is uniformly 255.
>>
>> Any suggestions?
>>
>> Is it possible to specify that the distance map be 16 bit?
>>
>> newImage("Test", "8-bit White", 800, 800, 1);
>> run("Specify...", "width=700 height=700 x=400 y=400 oval centered");
>> run("Clear Outside");
>> run("Fill", "slice");
>> run("Select All");
>> run("Distance Map");
>>
>> Thanks in advance for any suggestions.
>>
>> Michael Ellis
>> www.dsuk.biz
Reply | Threaded
Open this post in threaded view
|

Re: Maximum Region Size for Distance Map limited by Map being 8 bit

Gabriel Landini
In reply to this post by Michael P Ellis
On Friday 03 Feb 2012 16:15:43 you wrote:
> I am writing a macro that attempts to create the largest circular region of
> interest that can be contained within the current region of interest. I am
> using the Distance Map function but have hit a limitation in that the
> Distance Map created is an 8 bit image and therefore the maximum distance
> that can be stored in the map is 255.

> Is it possible to specify that the distance map be 16 bit?

I wrote a macro EDM_16bits.txt which avoids this overflow (actually the limit
is 65535 instead of 255. It should be included in:

 http://www.dentistry.bham.ac.uk/landinig/software/morphology.zip

I think that Fiji has an exact distance transform plugin which might be better
and faster that this. And Bod Dougherty has a Local Thickness plugin that also
computes an exact distance transform.

Cheers
G