本文整理汇总了Python中skimage.filters.threshold_local方法的典型用法代码示例。如果您正苦于以下问题:Python filters.threshold_local方法的具体用法?Python filters.threshold_local怎么用?Python filters.threshold_local使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类skimage.filters
的用法示例。
在下文中一共展示了filters.threshold_local方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _local_thresholding
# 需要导入模块: from skimage import filters [as 别名]
# 或者: from skimage.filters import threshold_local [as 别名]
def _local_thresholding(im, padding=2, block_size=17, offset=70):
"""Local thresholding
Parameters
----------
im :
The camera frame with the eyes
padding :
padding of the camera frame (Default value = 2)
block_size :
param offset: (Default value = 17)
offset :
(Default value = 70)
Returns
-------
type
thresholded image
"""
padded = _pad(im, padding, im.min())
return padded > threshold_local(padded, block_size=block_size, offset=offset)
示例2: adap
# 需要导入模块: from skimage import filters [as 别名]
# 或者: from skimage.filters import threshold_local [as 别名]
def adap(data, block_size, offset):
from skimage.filters import threshold_local
mask = data
for iz in range(data.shape[2]):
adaptive_thresh = threshold_local(data[:, :, iz], block_size, method='gaussian', offset=offset)
mask[:, :, iz] = mask[:, :, iz] > adaptive_thresh
return mask
示例3: get_bin_threshold
# 需要导入模块: from skimage import filters [as 别名]
# 或者: from skimage.filters import threshold_local [as 别名]
def get_bin_threshold(self, percent, high=True, adaptive=False, binary=True, img=False):
"""
Threshold the image into binary values
Parameters
----------
percent : float
The percentage where the thresholding is made
high : bool
If high a value of 1 is returned for values > percent
adaptive : bool
If True, performs an adaptive thresholding (see skimage.filters.threshold_adaptive)
binary : bool
If True return bool data (True/False) otherwise numeric (0/1)
img : bool
If True return a SPM_image otherwise a numpy array
"""
if adaptive:
if binary:
return self.pixels > threshold_local(self.pixels, percent)
return threshold_local(self.pixels, percent)
mi = np.min(self.pixels)
norm = (self.pixels-mi)/(np.max(self.pixels)-mi)
if high:
r = norm > percent
else:
r = norm < percent
if not img:
if binary:
return r
return np.ones(self.pixels.shape)*r
else:
I = copy.deepcopy(self)
I.channel = "Threshold from "+I.channel
if binary:
I.pixels = r
else:
I.pixels = np.ones(self.pixels.shape)*r
return I
示例4: binarize_images
# 需要导入模块: from skimage import filters [as 别名]
# 或者: from skimage.filters import threshold_local [as 别名]
def binarize_images(data):
binarized_data = []
for image in data:
image = image.reshape((62, 47))
image_threshold = threshold_local(image, block_size=15)
binary_adaptive_image = image > image_threshold
binarized_data.append(binary_adaptive_image.ravel())
return asfloat(binarized_data)