SHARE
TWEET

Untitled

a guest Apr 18th, 2019 72 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     def update_isolatedness(self, maxima, step, point_data_list):
  2.         for maximum_a in maxima[:self.parameters['maxima_per_iter']]:
  3.             distances = []
  4.             for maximum_b in maxima:
  5.                 distances.append(Util.distance_eu(maximum_a[0], maximum_b[0]))
  6.             distances.sort()
  7.             isolatedness = 0
  8.             for d in distances[1:self.parameters['furthest_index']]:
  9.                 isolatedness += d
  10.             point_data_list.set(maximum_a, isolatedness, step)
  11.  
  12.     def update_point_data_list(self, smoothed, sigma, step, point_data_list):
  13.         """"""
  14.         maxima = Util.local_maxima(smoothed)
  15.         if sigma >= 0.5:
  16.             maxima = gi.optimize_maxima(smoothed, maxima, sigma)
  17.         maxima = Util.sort_list(maxima, 1, True)
  18.         self.update_isolatedness(maxima, step, point_data_list)
  19.  
  20.     def smooth_image(self, sigma, last_sigma, smoothed):
  21.         if last_sigma == 0 or sigma <= last_sigma:
  22.             smoothed = cv.GaussianBlur(self.matrix, Util.kernel_size(sigma), sigma)
  23.         else:
  24.             sigma_to_add = math.sqrt(pow(sigma, 2) - pow(last_sigma, 2))
  25.             smoothed = cv.GaussianBlur(smoothed, Util.kernel_size(sigma_to_add), sigma_to_add)
  26.         return smoothed
  27.  
  28.     def compute_measure(self):
  29.         """"""
  30.         smoothed = None
  31.         last_sigma = 0
  32.         point_data_list = PointDataList(self.parameters['dist_thresh'])
  33.  
  34.         for step in range(0, len(self.parameters['sigma_array'])):
  35.             sigma = self.parameters['sigma_array'][step]
  36.             smoothed = self.smooth_image(sigma, last_sigma, smoothed)
  37.             last_sigma = sigma
  38.             self.update_point_data_list(smoothed, sigma, step, point_data_list)
  39.  
  40.         return point_data_list
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top