# Difference between revisions of "Max Inscribed Circles"

m |
(Fix "list of update sites" link) |
||

(9 intermediate revisions by one other user not shown) | |||

Line 6: | Line 6: | ||

| filename = Max_Inscribed_Circle.jar | | filename = Max_Inscribed_Circle.jar | ||

| released = August 2015 | | released = August 2015 | ||

− | | latest version = | + | | latest version = July 2016 |

− | | source = {{GitHub|org= | + | | source = {{GitHub|org=ptbiop|repo=ijp-max-inscribed-circles}} |

| status = stable | | status = stable | ||

| website = [http://biop.epfl.ch/INFO_Facility.html#staff BIOP Staff Page] | | website = [http://biop.epfl.ch/INFO_Facility.html#staff BIOP Staff Page] | ||

Line 16: | Line 16: | ||

The code for this plugin was inspired by this [http://www.mathworks.ch/matlabcentral/fileexchange/30805-maximum-inscribed-circle-using-distance-transform Matlab Central function] | The code for this plugin was inspired by this [http://www.mathworks.ch/matlabcentral/fileexchange/30805-maximum-inscribed-circle-using-distance-transform Matlab Central function] | ||

− | [[File: | + | [[File:Max_largest_circ_dialog2.png |500px|thumb|right|Plugin Dialog choices]] |

+ | == Details == | ||

+ | As of July 26th 2016, the plugin has been rewritten with a new algorithm to make it run much faster.. See the faster implementation details figure. | ||

+ | [[File:Max-Circles-Algorithm-Overview.png|400px|thumb|right|Faster implementation details]] | ||

+ | The previous implementation would calculate a distance map, then find the max value, place a circle and repeat. This was making it very slow for small circle diameters or large images as it needed to make one distance map calculation per circle on the whole image. | ||

+ | |||

+ | By using a Local Maxima Finder, we can draw multiple circles on a single pass, provided that these are | ||

+ | # The largest distances on the distance map image | ||

+ | # Not overlapping with one another | ||

+ | |||

+ | That way when there are plenty of circles that are the same size, we can draw them all at the same time. | ||

== Installation == | == Installation == | ||

− | This plugin is available from the | + | This plugin is available from the {{ListOfUpdateSites|BIOP Update Site}} |

This places it in a "BIOP" Folder in the plugins directory of Fiji/ImageJ | This places it in a "BIOP" Folder in the plugins directory of Fiji/ImageJ | ||

== Use == | == Use == | ||

− | Call up the plugin using ''Plugins->BIOP->Max Inscribed Circles...'' | + | Call up the plugin using ''Plugins->BIOP->Max Inscribed Circles...''. |

+ | |||

+ | You can select the smallest circle diameter after which it will stop looking, and whether you want the plugin to run on the current selection or the current image mask. | ||

It will add all the found circles to the ROI Manager. | It will add all the found circles to the ROI Manager. | ||

Line 30: | Line 42: | ||

Setting the Minimum Disk Diameter to 0 will return a single ROI with the largest inscribed circle. | Setting the Minimum Disk Diameter to 0 will return a single ROI with the largest inscribed circle. | ||

− | [[File:Max_largest_circ_beforeafter.png|400px|thumb|right| | + | [[File:Max_largest_circ_beforeafter.png|400px|thumb|right|Result of Plugin on whole image]] |

Line 49: | Line 61: | ||

<source lang="java"> | <source lang="java"> | ||

//imp must be an 8-bit binary image | //imp must be an 8-bit binary image | ||

− | ArrayList<Roi> circles = MaxInscribedCircles.findCircles(ImagePlus imp, double minD); | + | ArrayList<Roi> circles = MaxInscribedCircles.findCircles(ImagePlus imp, double minD, boolean isSelectionOnly); |

</source> | </source> | ||

+ | Set the last argument <pre>isSelectionOnly</pre> to true if you want to fit circles in the current selection. If you'd like to use the pixel mask, set it to false. | ||

== Notes == | == Notes == | ||

− | |||

− | |||

The accuracy is not perfect as we are using the distance map which has finite values. But for most practical purposes (Circles larger than 2 pixels in diameter), it should be sufficient. | The accuracy is not perfect as we are using the distance map which has finite values. But for most practical purposes (Circles larger than 2 pixels in diameter), it should be sufficient. | ||

[[Category:Plugins]] | [[Category:Plugins]] |

## Latest revision as of 17:25, 13 December 2018

Max Inscribed Circles (Fiji) | |
---|---|

Author | Olivier Burri, Romain Guiet |

Maintainer | Olivier Burri |

File | Max_Inscribed_Circle.jar |

Source | on GitHub |

Initial release | August 2015 |

Latest version | July 2016 |

Development status | stable |

Website | BIOP Staff Page |

## Contents

## Purpose

This is an implementation of the Largest Inscribed Circle algorithm using an euclidean distance map. The algorithm is looped until a circle diameter smaller than the defined minimum diameter is found. The code for this plugin was inspired by this Matlab Central function

## Details

As of July 26th 2016, the plugin has been rewritten with a new algorithm to make it run much faster.. See the faster implementation details figure.

The previous implementation would calculate a distance map, then find the max value, place a circle and repeat. This was making it very slow for small circle diameters or large images as it needed to make one distance map calculation per circle on the whole image.

By using a Local Maxima Finder, we can draw multiple circles on a single pass, provided that these are

- The largest distances on the distance map image
- Not overlapping with one another

That way when there are plenty of circles that are the same size, we can draw them all at the same time.

## Installation

This plugin is available from the BIOP Update Site This places it in a "BIOP" Folder in the plugins directory of Fiji/ImageJ

## Use

Call up the plugin using *Plugins->BIOP->Max Inscribed Circles...*.

You can select the smallest circle diameter after which it will stop looking, and whether you want the plugin to run on the current selection or the current image mask.

It will add all the found circles to the ROI Manager.

Setting the Minimum Disk Diameter to 0 will return a single ROI with the largest inscribed circle.

## Macro Recordable

Making use of the GenericDialog class, the plugin is macro-recordable.

run("Max Inscribed Circles...", "minimum=20");

## Running from a Plugin

What you need to run this in a plugin is

import ch.epfl.biop.MaxInscribedCircles;

And then call the static method

//imp must be an 8-bit binary image ArrayList<Roi> circles = MaxInscribedCircles.findCircles(ImagePlus imp, double minD, boolean isSelectionOnly);Set the last argument

isSelectionOnlyto true if you want to fit circles in the current selection. If you'd like to use the pixel mask, set it to false.

## Notes

The accuracy is not perfect as we are using the distance map which has finite values. But for most practical purposes (Circles larger than 2 pixels in diameter), it should be sufficient.