本文整理匯總了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)