当前位置: 首页>>代码示例>>Python>>正文


Python skimage.measure方法代码示例

本文整理汇总了Python中skimage.measure方法的典型用法代码示例。如果您正苦于以下问题:Python skimage.measure方法的具体用法?Python skimage.measure怎么用?Python skimage.measure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在skimage的用法示例。


在下文中一共展示了skimage.measure方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: measure_registration_single

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import measure [as 别名]
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 
开发者ID:Borda,项目名称:BIRL,代码行数:25,代码来源:bm_comp_perform.py

示例2: generate_markers

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import measure [as 别名]
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 
开发者ID:Wrosinski,项目名称:Kaggle-DSB,代码行数:24,代码来源:dsbowl_preprocess_2d.py

示例3: measure_registration_parallel

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import measure [as 别名]
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 
开发者ID:Borda,项目名称:BIRL,代码行数:34,代码来源:bm_comp_perform.py

示例4: get_masks

# 需要导入模块: import skimage [as 别名]
# 或者: from skimage import measure [as 别名]
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:] 
开发者ID:whdcumt,项目名称:BlurDetection,代码行数:14,代码来源:FocusMask.py


注:本文中的skimage.measure方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。