Ask Your Question

Revision history [back]

Seiko,
unless you posted this question some months ago I still stumbled into the same unanswered question. My answer would be:
 Why don't you simply  
1. do a distance transform (in python for example using ndimage.distance_transform_edt explained [here](http://pythonvision.org/basic-tutorial) some way down the page)
2. take the point with the largest distance as center and
3. take the corresponding distance as the radius?
The result should be a fastly computed maximum enclosed circle for all types of polygons.
Or am I wrong somehow?
Greets,
Frank
Seiko,

Seiko,

unless you posted this question some months ago I still stumbled into the same unanswered question. My answer would be: Why don't you simply

1.
  1. do a distance transform (in python for example using ndimage.distance_transform_edt explained [here](http://pythonvision.org/basic-tutorial) here some way down the page) 2. page)

  2. take the point with the largest distance as center and 3. and

  3. take the corresponding distance as the radius? radius?

The result should be a fastly computed maximum enclosed circle for all types of polygons. Or am I wrong somehow? Greets, Frank

Frank

Seiko,

unless you posted this question some months ago I still stumbled into the same unanswered question. My answer would be: Why don't you simply

  1. do a distance transform (in python for example using ndimage.distance_transform_edt explained here some way down the page)

  2. take the point with the largest distance as center and

  3. take the corresponding distance as the radius?

The result should be a fastly computed maximum enclosed circle for all types of polygons. Or am I wrong somehow? Greets, Frank

#   +++calculate maximum enclosed circle+++

def maxEnclosedCircle(binent): 
# binent is an array where the shape of interest has a value larger than 0

    #distance transform
    dist = ndimage.distance_transform_edt(binent>0)

    #set radius to largest distance

    radius=np.amax(dist)

    #get index
    flatind=np.argmax(dist)#index of flattened arrays
    ind=np.unravel(flatind,dist.size)#convert to 2D index

    #check if multiple maxima exist and how many
    a=len(dist[dist==radius])

    return ind,radius,a