Advertisement
ayush3504

Untitled

Nov 30th, 2015
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. for each circle i:
  2.     neighbour_list = []  #init list of neighbours
  3.     for each circle j:  #for each neighbour
  4.         d = distance(i,j))  #compute distance
  5.         if d < range:  # if its within range
  6.             neighbour_list.append(j)   #add neighbour to the list
  7.     neighbour_list.append(i)  # adding itself to the list
  8.  
  9.     # now we go through the list of neighbours including circle i and find out the largest circle
  10.     for k in neighbour_list:
  11.         m = 0 # temp value for comparison
  12.         largest_circle = circle_type # stores circle object / id / coordinates
  13.         if area(k) > m:  #if area of circle k is larger than what's stored in m
  14.             m = area(k)  #update m
  15.             largest_circle = area(k)  #set largest (so far) circle k
  16.  
  17.     # now we delete all circles from image except largest_circle
  18.     for x in neighbour_list:
  19.         if x != largest_circle:
  20.             delete(x)  #deletes circle from image
  21.  
  22.     return largest_circle # optional
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement