예제 #1
0
def support_threshold(threshold, blur_radius):
    """Create a support update array with only a threshold support."""
    threshold_sp = smap(threshold)
    blur_radius_sp = smap(blur_radius)
    algorithm = _spimage.sp_support_array_init(
        _spimage.sp_support_threshold_alloc(blur_radius_sp, threshold_sp), 20)
    return algorithm
 def _init_support_algorithms(self):
     if not self._support_algorithms_dirty:
         self._log("Support algorithms already initialised.","DEBUG")
         return       
     i = 0
     for alg_conf in self._support_algorithms_configs:
         alg = dict(alg_conf)
         if alg_conf["number_of_iterations"] is None:
             if len(self._support_algorithms_configs) == 1:
                 alg["number_of_iterations"] = self._number_of_iterations
             else:
                 self._log("Number of iterations can not be None if many support algorithms are specified. Please report this error.","ERROR")
                 return
         if alg["type"] == "area":
             blur_radius = spimage.sp_smap_alloc(2)
             spimage.sp_smap_insert(blur_radius, i, alg["blur_init"])
             spimage.sp_smap_insert(blur_radius, i + alg["number_of_iterations"], alg["blur_final"])
             support_area = spimage.sp_smap_alloc(2)
             spimage.sp_smap_insert(support_area, i,alg["area_init"])
             spimage.sp_smap_insert(support_area, i + alg["number_of_iterations"],alg["area_final"])
             alg["spimage_support_array"] = spimage.sp_support_array_init(spimage.sp_support_area_alloc(blur_radius, support_area),alg["update_period"])
         elif alg["type"] == "threshold":
             blur_radius = spimage.sp_smap_alloc(2)
             spimage.sp_smap_insert(blur_radius, i, alg["blur_init"])
             spimage.sp_smap_insert(blur_radius, i + alg["number_of_iterations"], alg["blur_final"])
             threshold = spimage.sp_smap_alloc(2)
             spimage.sp_smap_insert(threshold, i, alg["threshold_init"])
             spimage.sp_smap_insert(threshold, i + alg["number_of_iterations"], alg["threshold_final"])
             alg["spimage_support_array"] = spimage.sp_support_array_init(spimage.sp_support_threshold_alloc(blur_radius, threshold),alg["update_period"])
         elif alg["type"] == "static":
             alg["update_period"] = alg["number_of_iterations"]
             alg["spimage_support_array"] = spimage.sp_support_array_init(spimage.sp_support_static_alloc(),alg["update_period"])
         else:
             self._log("No valid support algorithm set. This error should be reported!","ERROR")
             return
         if alg["center_image"]:
             spimage.sp_support_array_append(alg["spimage_support_array"],spimage.sp_support_centre_image_alloc())
             self._log("Enabling center image in real space, it will be done with every support update.")
         else:
             self._log("Center real space image disabled.")
         i += alg["number_of_iterations"]
         self._support_algorithms.append(alg)
     self._support_algorithms_dirty = False
     self._log("Support algorithms initialised.","DEBUG")
 def _init_support_algorithms(self):
     if not self._support_algorithms_dirty:
         self._log("Support algorithms already initialised.","DEBUG")
         return       
     i = 0
     for alg_conf in self._support_algorithms_configs:
         alg = dict(alg_conf)
         if alg_conf["number_of_iterations"] is None:
             if len(self._support_algorithms_configs) == 1:
                 alg["number_of_iterations"] = self._number_of_iterations
             else:
                 self._log("Number of iterations can not be None if many support algorithms are specified. Please report this error.","ERROR")
                 return
         if alg["type"] == "area":
             self._blur_radius = spimage.sp_smap_alloc(2)
             spimage.sp_smap_insert(self._blur_radius, i, alg["blur_init"])
             spimage.sp_smap_insert(self._blur_radius, i + alg["number_of_iterations"], alg["blur_final"])
             self._support_area = spimage.sp_smap_alloc(2)
             spimage.sp_smap_insert(self._support_area, i,alg["area_init"])
             spimage.sp_smap_insert(self._support_area, i + alg["number_of_iterations"],alg["area_final"])
             alg["spimage_support_array"] = spimage.sp_support_array_init(spimage.sp_support_area_alloc(self._blur_radius, self._support_area),alg["update_period"])
         elif alg["type"] == "threshold":
             self._blur_radius = spimage.sp_smap_alloc(2)
             spimage.sp_smap_insert(self._blur_radius, i, alg["blur_init"])
             spimage.sp_smap_insert(self._blur_radius, i + alg["number_of_iterations"], alg["blur_final"])
             self._threshold = spimage.sp_smap_alloc(2)
             spimage.sp_smap_insert(self._threshold, i, alg["threshold_init"])
             spimage.sp_smap_insert(self._threshold, i + alg["number_of_iterations"], alg["threshold_final"])
             alg["spimage_support_array"] = spimage.sp_support_array_init(spimage.sp_support_threshold_alloc(self._blur_radius, self._threshold),alg["update_period"])
         elif alg["type"] == "static":
             alg["update_period"] = alg["number_of_iterations"]
             alg["spimage_support_array"] = spimage.sp_support_array_init(spimage.sp_support_static_alloc(),alg["update_period"])
         else:
             self._log("No valid support algorithm set. This error should be reported!","ERROR")
             return
         if alg["center_image"]:
             spimage.sp_support_array_append(alg["spimage_support_array"],spimage.sp_support_centre_image_alloc())
             self._log("Enabling center image in real space, it will be done with every support update.")
         else:
             self._log("Center real space image disabled.")
         i += alg["number_of_iterations"]
         self._support_algorithms.append(alg)
     self._support_algorithms_dirty = False
     self._log("Support algorithms initialised.","DEBUG")
예제 #4
0
def support_threshold(threshold, blur_radius):
    """Create a support update array with only a threshold support."""
    threshold_sp = smap(threshold)
    blur_radius_sp = smap(blur_radius)
    algorithm = _spimage.sp_support_array_init(_spimage.sp_support_threshold_alloc(blur_radius_sp, threshold_sp), 20)
    return algorithm