Beispiel #1
0
 def run_one_gabor(self, image_name, object_name, scale, workspace):
     objects = workspace.get_objects(object_name)
     labels = objects.segmented
     object_count = np.max(labels)
     if object_count > 0:
         image = workspace.image_set.get_image(image_name,
                                               must_be_grayscale=True)
         pixel_data = image.pixel_data
         labels = objects.segmented
         if image.has_mask:
             mask = image.mask
         else:
             mask = None
         try:
             pixel_data = objects.crop_image_similarly(pixel_data)
             if mask is not None:
                 mask = objects.crop_image_similarly(mask)
                 labels[~mask] = 0
         except ValueError:
             pixel_data, m1 = cpo.size_similarly(labels, pixel_data)
             labels[~m1] = 0
             if mask is not None:
                 mask, m2 = cpo.size_similarly(labels, mask)
                 labels[~m2] = 0
                 labels[~mask] = 0
         pixel_data = normalized_per_object(pixel_data, labels)
         best_score = np.zeros((object_count,))
         for angle in range(self.gabor_angles.value):
             theta = np.pi * angle / self.gabor_angles.value
             g = gabor(pixel_data, labels, scale, theta)
             score_r = fix(scind.sum(g.real, labels,
                                      np.arange(object_count, dtype=np.int32)+ 1))
             score_i = fix(scind.sum(g.imag, labels,
                                      np.arange(object_count, dtype=np.int32)+ 1))
             score = np.sqrt(score_r**2+score_i**2)
             best_score = np.maximum(best_score, score)
     else:
         best_score = np.zeros((0,))
     statistics = self.record_measurement(workspace, 
                                          image_name, 
                                          object_name, 
                                          scale,
                                          F_GABOR, 
                                          best_score)
     return statistics
Beispiel #2
0
 def run_one_gabor(self, image_name, object_name, scale, workspace):
     objects = workspace.get_objects(object_name)
     labels = objects.segmented
     object_count = np.max(labels)
     if object_count > 0:
         image = workspace.image_set.get_image(image_name,
                                               must_be_grayscale=True)
         pixel_data = image.pixel_data
         labels = objects.segmented
         if image.has_mask:
             mask = image.mask
         else:
             mask = None
         try:
             pixel_data = objects.crop_image_similarly(pixel_data)
             if mask is not None:
                 mask = objects.crop_image_similarly(mask)
                 labels[~mask] = 0
         except ValueError:
             pixel_data, m1 = cpo.size_similarly(labels, pixel_data)
             labels[~m1] = 0
             if mask is not None:
                 mask, m2 = cpo.size_similarly(labels, mask)
                 labels[~m2] = 0
                 labels[~mask] = 0
         pixel_data = normalized_per_object(pixel_data, labels)
         best_score = np.zeros((object_count, ))
         for angle in range(self.gabor_angles.value):
             theta = np.pi * angle / self.gabor_angles.value
             g = gabor(pixel_data, labels, scale, theta)
             score_r = fix(
                 scind.sum(g.real, labels,
                           np.arange(object_count, dtype=np.int32) + 1))
             score_i = fix(
                 scind.sum(g.imag, labels,
                           np.arange(object_count, dtype=np.int32) + 1))
             score = np.sqrt(score_r**2 + score_i**2)
             best_score = np.maximum(best_score, score)
     else:
         best_score = np.zeros((0, ))
     statistics = self.record_measurement(workspace, image_name,
                                          object_name, scale, F_GABOR,
                                          best_score)
     return statistics
Beispiel #3
0
 def run_image_gabor(self, image_name, scale, workspace):
     image = workspace.image_set.get_image(image_name,
                                           must_be_grayscale=True)
     pixel_data = image.pixel_data
     labels = np.ones(pixel_data.shape, int)
     if image.has_mask:
         labels[~image.mask] = 0
     pixel_data = stretch(pixel_data, labels > 0)
     best_score = 0
     for angle in range(self.gabor_angles.value):
         theta = np.pi * angle / self.gabor_angles.value
         g = gabor(pixel_data, labels, scale, theta)
         score_r = np.sum(g.real)
         score_i = np.sum(g.imag)
         score = np.sqrt(score_r**2 + score_i**2)
         best_score = max(best_score, score)
     statistics = self.record_image_measurement(workspace, image_name,
                                                scale, F_GABOR, best_score)
     return statistics
Beispiel #4
0
 def run_image_gabor(self, image_name, scale, workspace):
     image = workspace.image_set.get_image(image_name,
                                           must_be_grayscale=True)
     pixel_data = image.pixel_data
     labels = np.ones(pixel_data.shape, int)
     if image.has_mask:
         labels[~image.mask] = 0
     pixel_data = stretch(pixel_data, labels > 0)
     best_score = 0
     for angle in range(self.gabor_angles.value):
         theta = np.pi * angle / self.gabor_angles.value
         g = gabor(pixel_data, labels, scale, theta)
         score_r = np.sum(g.real)
         score_i = np.sum(g.imag)
         score = np.sqrt(score_r**2+score_i**2)
         best_score = max(best_score, score)
     statistics = self.record_image_measurement(workspace, 
                                                image_name, 
                                                scale,
                                                F_GABOR, 
                                                best_score)
     return statistics