當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。