Python skimage.measure() Examples
The following are 6
code examples of skimage.measure().
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
, or try the search function
.
Example #1
Source File: bm_comp_perform.py From BIRL with BSD 3-Clause "New" or "Revised" License | 6 votes |
def measure_registration_single(path_out, nb_iter=5): """ measure mean execration time for image registration running in 1 thread :param str path_out: path to the temporary output space :param int nb_iter: number of experiments to be averaged :return dict: dictionary of float values results """ path_img_target, path_img_source = _prepare_images(path_out, IMAGE_SIZE) paths = [path_img_target, path_img_source] execution_times = [] for i in tqdm.tqdm(range(nb_iter), desc='using single-thread'): path_img_warped, t = register_image_pair(i, path_img_target, path_img_source, path_out) paths.append(path_img_warped) execution_times.append(t) _clean_images(set(paths)) logging.info('registration @1-thread: %f +/- %f', np.mean(execution_times), np.std(execution_times)) res = {'registration @1-thread': np.mean(execution_times)} return res
Example #2
Source File: dsbowl_preprocess_2d.py From Kaggle-DSB with MIT License | 6 votes |
def generate_markers(image): #Creation of the internal Marker marker_internal = image < -400 marker_internal = segmentation.clear_border(marker_internal) marker_internal_labels = measure.label(marker_internal) areas = [r.area for r in measure.regionprops(marker_internal_labels)] areas.sort() if len(areas) > 2: for region in measure.regionprops(marker_internal_labels): if region.area < areas[-2]: for coordinates in region.coords: marker_internal_labels[coordinates[0], coordinates[1]] = 0 marker_internal = marker_internal_labels > 0 #Creation of the external Marker external_a = ndimage.binary_dilation(marker_internal, iterations=10) external_b = ndimage.binary_dilation(marker_internal, iterations=55) marker_external = external_b ^ external_a #Creation of the Watershed Marker matrix marker_watershed = np.zeros(image.shape, dtype=np.int) marker_watershed += marker_internal * 255 marker_watershed += marker_external * 128 return marker_internal, marker_external, marker_watershed
Example #3
Source File: LUNA_3d_merge_preproc.py From Kaggle-DSB with MIT License | 6 votes |
def generate_markers(image): #Creation of the internal Marker marker_internal = image < -400 marker_internal = segmentation.clear_border(marker_internal) marker_internal_labels = measure.label(marker_internal) areas = [r.area for r in measure.regionprops(marker_internal_labels)] areas.sort() if len(areas) > 2: for region in measure.regionprops(marker_internal_labels): if region.area < areas[-2]: for coordinates in region.coords: marker_internal_labels[coordinates[0], coordinates[1]] = 0 marker_internal = marker_internal_labels > 0 #Creation of the external Marker external_a = ndimage.binary_dilation(marker_internal, iterations=10) external_b = ndimage.binary_dilation(marker_internal, iterations=55) marker_external = external_b ^ external_a #Creation of the Watershed Marker matrix marker_watershed = np.zeros(image.shape, dtype=np.int) marker_watershed += marker_internal * 255 marker_watershed += marker_external * 128 return marker_internal, marker_external, marker_watershed
Example #4
Source File: preproc_utils.py From Kaggle-DSB with MIT License | 6 votes |
def generate_markers(image): #Creation of the internal Marker marker_internal = image < -400 marker_internal = segmentation.clear_border(marker_internal) marker_internal_labels = measure.label(marker_internal) areas = [r.area for r in measure.regionprops(marker_internal_labels)] areas.sort() if len(areas) > 2: for region in measure.regionprops(marker_internal_labels): if region.area < areas[-2]: for coordinates in region.coords: marker_internal_labels[coordinates[0], coordinates[1]] = 0 marker_internal = marker_internal_labels > 0 #Creation of the external Marker external_a = ndimage.binary_dilation(marker_internal, iterations=10) external_b = ndimage.binary_dilation(marker_internal, iterations=55) marker_external = external_b ^ external_a #Creation of the Watershed Marker matrix marker_watershed = np.zeros(image.shape, dtype=np.int) marker_watershed += marker_internal * 255 marker_watershed += marker_external * 128 return marker_internal, marker_external, marker_watershed
Example #5
Source File: bm_comp_perform.py From BIRL with BSD 3-Clause "New" or "Revised" License | 5 votes |
def measure_registration_parallel(path_out, nb_iter=3, nb_workers=CPU_COUNT): """ measure mean execration time for image registration running in N thread :param str path_out: path to the temporary output space :param int nb_iter: number of experiments to be averaged :param int nb_workers: number of thread available on the computer :return dict: dictionary of float values results """ path_img_target, path_img_source = _prepare_images(path_out, IMAGE_SIZE) paths = [path_img_target, path_img_source] execution_times = [] _regist = partial(register_image_pair, path_img_target=path_img_target, path_img_source=path_img_source, path_out=path_out) nb_tasks = int(nb_workers * nb_iter) logging.info('>> running %i tasks in %i threads', nb_tasks, nb_workers) tqdm_bar = tqdm.tqdm(total=nb_tasks, desc='parallel @ %i threads' % nb_workers) pool = mproc.Pool(nb_workers) for path_img_warped, t in pool.map(_regist, (range(nb_tasks))): paths.append(path_img_warped) execution_times.append(t) tqdm_bar.update() pool.close() pool.join() tqdm_bar.close() _clean_images(set(paths)) logging.info('registration @%i-thread: %f +/- %f', nb_workers, np.mean(execution_times), np.std(execution_times)) res = {'registration @n-thread': np.mean(execution_times)} return res
Example #6
Source File: FocusMask.py From BlurDetection with MIT License | 5 votes |
def get_masks(img, n_seg=250): logger.debug('SLIC segmentation initialised') segments = skimage.segmentation.slic(img, n_segments=n_seg, compactness=10, sigma=1) logger.debug('SLIC segmentation complete') logger.debug('contour extraction...') masks = [[numpy.zeros((img.shape[0], img.shape[1]), dtype=numpy.uint8), None]] for region in skimage.measure.regionprops(segments): masks.append([masks[0][0].copy(), region.bbox]) x_min, y_min, x_max, y_max = region.bbox masks[-1][0][x_min:x_max, y_min:y_max] = skimage.img_as_ubyte(region.convex_image) logger.debug('contours extracted') return masks[1:]