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


Python signal.medfilt2d方法代码示例

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


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

示例1: test_basic

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import medfilt2d [as 别名]
def test_basic(self):
        f = [[50, 50, 50, 50, 50, 92, 18, 27, 65, 46],
             [50, 50, 50, 50, 50, 0, 72, 77, 68, 66],
             [50, 50, 50, 50, 50, 46, 47, 19, 64, 77],
             [50, 50, 50, 50, 50, 42, 15, 29, 95, 35],
             [50, 50, 50, 50, 50, 46, 34, 9, 21, 66],
             [70, 97, 28, 68, 78, 77, 61, 58, 71, 42],
             [64, 53, 44, 29, 68, 32, 19, 68, 24, 84],
             [3, 33, 53, 67, 1, 78, 74, 55, 12, 83],
             [7, 11, 46, 70, 60, 47, 24, 43, 61, 26],
             [32, 61, 88, 7, 39, 4, 92, 64, 45, 61]]

        d = signal.medfilt(f, [7, 3])
        e = signal.medfilt2d(np.array(f, np.float), [7, 3])
        assert_array_equal(d, [[0, 50, 50, 50, 42, 15, 15, 18, 27, 0],
                               [0, 50, 50, 50, 50, 42, 19, 21, 29, 0],
                               [50, 50, 50, 50, 50, 47, 34, 34, 46, 35],
                               [50, 50, 50, 50, 50, 50, 42, 47, 64, 42],
                               [50, 50, 50, 50, 50, 50, 46, 55, 64, 35],
                               [33, 50, 50, 50, 50, 47, 46, 43, 55, 26],
                               [32, 50, 50, 50, 50, 47, 46, 45, 55, 26],
                               [7, 46, 50, 50, 47, 46, 46, 43, 45, 21],
                               [0, 32, 33, 39, 32, 32, 43, 43, 43, 0],
                               [0, 7, 11, 7, 4, 4, 19, 19, 24, 0]])
        assert_array_equal(d, e) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:27,代码来源:test_signaltools.py

示例2: test_basic

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import medfilt2d [as 别名]
def test_basic(self):
        f = [[50, 50, 50, 50, 50, 92, 18, 27, 65, 46],
             [50, 50, 50, 50, 50, 0, 72, 77, 68, 66],
             [50, 50, 50, 50, 50, 46, 47, 19, 64, 77],
             [50, 50, 50, 50, 50, 42, 15, 29, 95, 35],
             [50, 50, 50, 50, 50, 46, 34, 9, 21, 66],
             [70, 97, 28, 68, 78, 77, 61, 58, 71, 42],
             [64, 53, 44, 29, 68, 32, 19, 68, 24, 84],
             [3, 33, 53, 67, 1, 78, 74, 55, 12, 83],
             [7, 11, 46, 70, 60, 47, 24, 43, 61, 26],
             [32, 61, 88, 7, 39, 4, 92, 64, 45, 61]]

        d = signal.medfilt(f, [7, 3])
        e = signal.medfilt2d(np.array(f, float), [7, 3])
        assert_array_equal(d, [[0, 50, 50, 50, 42, 15, 15, 18, 27, 0],
                               [0, 50, 50, 50, 50, 42, 19, 21, 29, 0],
                               [50, 50, 50, 50, 50, 47, 34, 34, 46, 35],
                               [50, 50, 50, 50, 50, 50, 42, 47, 64, 42],
                               [50, 50, 50, 50, 50, 50, 46, 55, 64, 35],
                               [33, 50, 50, 50, 50, 47, 46, 43, 55, 26],
                               [32, 50, 50, 50, 50, 47, 46, 45, 55, 26],
                               [7, 46, 50, 50, 47, 46, 46, 43, 45, 21],
                               [0, 32, 33, 39, 32, 32, 43, 43, 43, 0],
                               [0, 7, 11, 7, 4, 4, 19, 19, 24, 0]])
        assert_array_equal(d, e) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:27,代码来源:test_signaltools.py

示例3: overlay_edges

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import medfilt2d [as 别名]
def overlay_edges(slice_one, slice_two, sharper=True):
    """
    Makes a composite image with edges from second image overlaid on first.

    It will be in colormapped (RGB format) already.
    """

    if slice_one.shape != slice_two.shape:
        raise ValueError("slices' dimensions do not match: "
                         " {} and {} ".format(slice_one.shape, slice_two.shape))

    # simple filtering to remove noise, while supposedly keeping edges
    slice_two = medfilt2d(slice_two, kernel_size=cfg.median_filter_size)
    # extracting edges
    edges = np.hypot(sobel(slice_two, axis=0, mode='constant'),
                     sobel(slice_two, axis=1, mode='constant'))

    # trying to remove weak edges
    if not sharper: # level of removal
        edges = med_filter(max_filter(min_filter(edges)))
    else:
        edges = min_filter(min_filter(max_filter(min_filter(edges))))
    edges_color_mapped = hot_cmap(edges, alpha=cfg.alpha_edge_overlay_alignment)
    composite = gray_cmap(slice_one, alpha=cfg.alpha_background_slice_alignment)

    composite[edges_color_mapped>0] = edges_color_mapped[edges_color_mapped>0]

    # mask_rgba = np.dstack([edges>0] * 4)
    # composite[mask_rgba] = edges_color_mapped[mask_rgba]

    return composite 
开发者ID:raamana,项目名称:visualqc,代码行数:33,代码来源:image_utils.py

示例4: dwi_overlay_edges

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import medfilt2d [as 别名]
def dwi_overlay_edges(slice_one, slice_two):
    """
    Makes a composite image with edges from second image overlaid on first.

    It will be in colormapped (RGB format) already.
    """

    if slice_one.shape != slice_two.shape:
        raise ValueError("slices' dimensions do not match: "
                         " {} and {} ".format(slice_one.shape, slice_two.shape))

    # simple filtering to remove noise, while supposedly keeping edges
    slice_two = medfilt2d(slice_two, kernel_size=cfg.median_filter_size)
    # extracting edges
    edges = med_filter(np.hypot(sobel(slice_two, axis=0, mode='constant'),
                                sobel(slice_two, axis=1, mode='constant')))

    edges_color_mapped = hot_cmap(edges, alpha=cfg.alpha_edge_overlay_alignment)
    composite = gray_cmap(slice_one, alpha=cfg.alpha_background_slice_alignment)

    composite[edges_color_mapped>0] = edges_color_mapped[edges_color_mapped>0]

    # mask_rgba = np.dstack([edges>0] * 4)
    # composite[mask_rgba] = edges_color_mapped[mask_rgba]

    return composite 
开发者ID:raamana,项目名称:visualqc,代码行数:28,代码来源:image_utils.py

示例5: pit_filter

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import medfilt2d [as 别名]
def pit_filter(self, kernel_size):
        """
        Filters pits in the raster. Intended for use with canopy height models (i.e. grid(0.5).interpolate("max", "z").
        This function modifies the raster array **in place**.
        
        :param kernel_size: The size of the kernel window to pass over the array. For example 3 -> 3x3 kernel window.
        """
        from scipy.signal import medfilt2d

        self.array = medfilt2d(self.array, kernel_size=kernel_size) 
开发者ID:brycefrank,项目名称:pyfor,代码行数:12,代码来源:rasterizer.py

示例6: generate_depth_image

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import medfilt2d [as 别名]
def generate_depth_image(vertices, kpt, shape, isMedFilter=False):
    vertices_map = convert_vertices_2_map_interp2d_directly(vertices, shape)

    if isMedFilter:
        vertices_map_med = signal.medfilt2d(vertices_map, (5,5))
        vertices_map[vertices_map==0] = vertices_map_med[vertices_map==0]

    depth_map = np.array(vertices_map, np.uint8)

    return depth_map 
开发者ID:clks-wzz,项目名称:PRNet-Depth-Generation,代码行数:12,代码来源:depth_image.py

示例7: enhanced_mean_image

# 需要导入模块: from scipy import signal [as 别名]
# 或者: from scipy.signal import medfilt2d [as 别名]
def enhanced_mean_image(ops):
    """ computes enhanced mean image and adds it to ops

    Median filters ops['meanImg'] with 4*diameter in 2D and subtracts and
    divides by this median-filtered image to return a high-pass filtered
    image ops['meanImgE']

    Parameters
    ----------
    ops : dictionary
        uses 'meanImg', 'aspect', 'diameter', 'yrange' and 'xrange'

    Returns
    -------
        ops : dictionary
            'meanImgE' field added

    """

    I = ops['meanImg'].astype(np.float32)
    if 'spatscale_pix' not in ops:
        if isinstance(ops['diameter'], int):
            diameter = np.array([ops['diameter'], ops['diameter']])
        else:
            diameter = np.array(ops['diameter'])
        ops['spatscale_pix'] = diameter[1]
        ops['aspect'] = diameter[0]/diameter[1]

    diameter = 4*np.ceil(np.array([ops['spatscale_pix'] * ops['aspect'], ops['spatscale_pix']])) + 1
    diameter = diameter.flatten().astype(np.int64)
    Imed = signal.medfilt2d(I, [diameter[0], diameter[1]])
    I = I - Imed
    Idiv = signal.medfilt2d(np.absolute(I), [diameter[0], diameter[1]])
    I = I / (1e-10 + Idiv)
    mimg1 = -6
    mimg99 = 6
    mimg0 = I

    mimg0 = mimg0[ops['yrange'][0]:ops['yrange'][1], ops['xrange'][0]:ops['xrange'][1]]
    mimg0 = (mimg0 - mimg1) / (mimg99 - mimg1)
    mimg0 = np.maximum(0,np.minimum(1,mimg0))
    mimg = mimg0.min() * np.ones((ops['Ly'],ops['Lx']),np.float32)
    mimg[ops['yrange'][0]:ops['yrange'][1],
        ops['xrange'][0]:ops['xrange'][1]] = mimg0
    ops['meanImgE'] = mimg
    return ops 
开发者ID:MouseLand,项目名称:suite2p,代码行数:48,代码来源:extract.py


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