58a220cb0fa5ea7d86486f1b3af8036b905de081,cellprofiler/modules/applythreshold.py,ApplyThreshold,_threshold_otsu3,#ApplyThreshold#Any#,787
Before Change
// using. Without a lower bound, you start having crazy threshold s that detect noise blobs. And same for
// very crowded areas where there is zero background in the window. You want the foreground to be all
// detected.
t_min = max(self .threshold_range.min, t_global * 0.7)
t_max = min(self.threshold_range.max, t_global * 1.5)
t_local[t_local < t_min] = t_min
t_local[t_local > t_max] = t_max
return t_local, t_global
t_local = t_global * self.threshold_correction_factor.value
return min(max(t_local, self.threshold_range.min), self.threshold_range.max), t_global
def _threshold_robust_background(self, image):
average_fn = {
RB_MEAN: numpy.mean,
After Change
return skimage.img_as_float(t_local)
def _threshold_otsu3(self , image):
data = image.pixel_data
mask = image.mask
t_global = centrosome.threshold.get_otsu_threshold(
data,
mask,
two_class_otsu=False,
assign_middle_to_foreground=self.assign_middle_to_foreground.value == O_FOREGROUND
)
t_global = self._correct_global_threshold(t_global)
if self.threshold_scope.value == TS_ADAPTIVE:
if image.volumetric:
t_local = numpy.zeros_like(data)
for index, plane in enumerate(data):
t_local[index] = centrosome.threshold.get_adaptive_threshold(
centrosome.threshold.TM_OTSU,
plane,
t_global,
mask=mask[index],
adaptive_window_size=3,
two_class_otsu=False,
assign_middle_to_foreground=self.assign_middle_to_foreground.value == O_FOREGROUND
)
else:
t_local = centrosome.threshold.get_adaptive_threshold(
centrosome.threshold.TM_OTSU,
data,
t_global,
mask=mask,
adaptive_window_size=3,
two_class_otsu=False,
assign_middle_to_foreground=self.assign_middle_to_foreground.value == O_FOREGROUND
)
t_local = self._correct_local_threshold(t_local, t_global)
return t_local, t_global
return t_global, t_global
def _threshold_robust_background(self, image):
average_fn = {
RB_MEAN: numpy.mean,
In pattern: SUPERPATTERN
Frequency: 3
Non-data size: 14
Instances Project Name: CellProfiler/CellProfiler
Commit Name: 58a220cb0fa5ea7d86486f1b3af8036b905de081
Time: 2017-02-22
Author: mcquin@broadinstitute.org
File Name: cellprofiler/modules/applythreshold.py
Class Name: ApplyThreshold
Method Name: _threshold_otsu3
Project Name: CellProfiler/CellProfiler
Commit Name: 58a220cb0fa5ea7d86486f1b3af8036b905de081
Time: 2017-02-22
Author: mcquin@broadinstitute.org
File Name: cellprofiler/modules/applythreshold.py
Class Name: ApplyThreshold
Method Name: _threshold_li
Project Name: CellProfiler/CellProfiler
Commit Name: ecf62ac20ef561df4265c3d1abd8c59b1e73895f
Time: 2020-06-11
Author: dstirling@broadinstitute.org
File Name: cellprofiler/modules/threshold.py
Class Name: Threshold
Method Name: get_threshold
Project Name: CellProfiler/CellProfiler
Commit Name: 58a220cb0fa5ea7d86486f1b3af8036b905de081
Time: 2017-02-22
Author: mcquin@broadinstitute.org
File Name: cellprofiler/modules/applythreshold.py
Class Name: ApplyThreshold
Method Name: _threshold_otsu3