Python skimage.filters.threshold_local() Examples
The following are 4
code examples of skimage.filters.threshold_local().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
skimage.filters
, or try the search function
.
Example #1
Source File: eyes.py From stytra with GNU General Public License v3.0 | 6 votes |
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)
Example #2
Source File: sct_maths.py From spinalcordtoolbox with MIT License | 5 votes |
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
Example #3
Source File: SPM.py From pySPM with Apache License 2.0 | 5 votes |
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
Example #4
Source File: rbm_faces_sampling.py From neupy with MIT License | 5 votes |
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)