コード例 #1
0
def test_correlate_library_to_pattern_fast_gpu(simulations, norim, nortemp):
    image = cp.ones((123, 50))
    cor = iutls.correlate_library_to_pattern_fast(
        image,
        simulations,
        delta_r=2.6,
        delta_theta=1.3,
        normalize_image=norim,
        normalize_templates=nortemp,
    )
    assert cor.shape[0] == 3
    assert is_cupy_array(cor)
コード例 #2
0
ファイル: expt_utils.py プロジェクト: tinabe/pyxem
def find_beam_center_blur(z, sigma):
    """Estimate direct beam position by blurring the image with a large
    Gaussian kernel and finding the maximum.

    Parameters
    ----------
    sigma : float
        Sigma value for Gaussian blurring kernel.

    Returns
    -------
    center : np.array
        np.array [x, y] containing indices of estimated direct beam positon.
    """
    if is_cupy_array(z):
        gaus = ndigpu.gaussian_filter
        dispatcher = cp
    else:
        gaus = ndi.gaussian_filter
        dispatcher = np
    blurred = gaus(z, sigma, mode="wrap")
    center = dispatcher.unravel_index(blurred.argmax(), blurred.shape)[::-1]
    return dispatcher.array(center)