ayush3504 icon

Untitled

ayush3504 | PRO | 12/01/15 02:35:58 AM UTC | 0 ⭐ | 306 👁️ | Never ⏰ | []
Python |

880 B

|

None

|

0 👍

/

0 👎

for each circle i:
    neighbour_list = []  #init list of neighbours
    for each circle j:  #for each neighbour
        d = distance(i,j))  #compute distance
        if d < range:  # if its within range
            neighbour_list.append(j)   #add neighbour to the list
    neighbour_list.append(i)  # adding itself to the list
 
    # now we go through the list of neighbours including circle i and find out the largest circle
    for k in neighbour_list:
        m = 0 # temp value for comparison
        largest_circle = circle_type # stores circle object / id / coordinates
        if area(k) > m:  #if area of circle k is larger than what's stored in m
            m = area(k)  #update m
            largest_circle = area(k)  #set largest (so far) circle k
 
    # now we delete all circles from image except largest_circle
    for x in neighbour_list:
        if x != largest_circle:
            delete(x)  #deletes circle from image
 
    return largest_circle # optional

Comments