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


Python fft.ifft2方法代码示例

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


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

示例1: wiener_dft

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def wiener_dft(im: np.ndarray, sigma: float) -> np.ndarray:
    """
    Adaptive Wiener filter applied to the 2D FFT of the image
    :param im: multidimensional array
    :param sigma: estimated noise power
    :return: filtered version of input im
    """
    noise_var = sigma ** 2
    h, w = im.shape

    im_noise_fft = fft2(im)
    im_noise_fft_mag = np.abs(im_noise_fft / (h * w) ** .5)

    im_noise_fft_mag_noise = wiener_adaptive(im_noise_fft_mag, noise_var)

    zeros_y, zeros_x = np.nonzero(im_noise_fft_mag == 0)

    im_noise_fft_mag[zeros_y, zeros_x] = 1
    im_noise_fft_mag_noise[zeros_y, zeros_x] = 0

    im_noise_fft_filt = im_noise_fft * im_noise_fft_mag_noise / im_noise_fft_mag
    im_noise_filt = np.real(ifft2(im_noise_fft_filt))

    return im_noise_filt.astype(np.float32) 
开发者ID:polimi-ispl,项目名称:prnu-python,代码行数:26,代码来源:functions.py

示例2: crosscorr_2d

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def crosscorr_2d(k1: np.ndarray, k2: np.ndarray) -> np.ndarray:
    """
    PRNU 2D cross-correlation
    :param k1: 2D matrix of size (h1,w1)
    :param k2: 2D matrix of size (h2,w2)
    :return: 2D matrix of size (max(h1,h2),max(w1,w2))
    """
    assert (k1.ndim == 2)
    assert (k2.ndim == 2)

    max_height = max(k1.shape[0], k2.shape[0])
    max_width = max(k1.shape[1], k2.shape[1])

    k1 -= k1.flatten().mean()
    k2 -= k2.flatten().mean()

    k1 = np.pad(k1, [(0, max_height - k1.shape[0]), (0, max_width - k1.shape[1])], mode='constant', constant_values=0)
    k2 = np.pad(k2, [(0, max_height - k2.shape[0]), (0, max_width - k2.shape[1])], mode='constant', constant_values=0)

    k1_fft = fft2(k1, )
    k2_fft = fft2(np.rot90(k2, 2), )

    return np.real(ifft2(k1_fft * k2_fft)).astype(np.float32) 
开发者ID:polimi-ispl,项目名称:prnu-python,代码行数:25,代码来源:functions.py

示例3: get_numpy

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def get_numpy(shape, fftn_shape=None, **kwargs):
    import numpy.fft as numpy_fft

    f = {
        "fft2": numpy_fft.fft2,
        "ifft2": numpy_fft.ifft2,
        "rfft2": numpy_fft.rfft2,
        "irfft2": lambda X: numpy_fft.irfft2(X, s=shape),
        "fftshift": numpy_fft.fftshift,
        "ifftshift": numpy_fft.ifftshift,
        "fftfreq": numpy_fft.fftfreq,
    }
    if fftn_shape is not None:
        f["fftn"] = numpy_fft.fftn
    fft = SimpleNamespace(**f)

    return fft 
开发者ID:pySTEPS,项目名称:pysteps,代码行数:19,代码来源:fft.py

示例4: get_scipy

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def get_scipy(shape, fftn_shape=None, **kwargs):
    import numpy.fft as numpy_fft
    import scipy.fftpack as scipy_fft

    # use numpy implementation of rfft2/irfft2 because they have not been
    # implemented in scipy.fftpack
    f = {
        "fft2": scipy_fft.fft2,
        "ifft2": scipy_fft.ifft2,
        "rfft2": numpy_fft.rfft2,
        "irfft2": lambda X: numpy_fft.irfft2(X, s=shape),
        "fftshift": scipy_fft.fftshift,
        "ifftshift": scipy_fft.ifftshift,
        "fftfreq": scipy_fft.fftfreq,
    }
    if fftn_shape is not None:
        f["fftn"] = scipy_fft.fftn
    fft = SimpleNamespace(**f)

    return fft 
开发者ID:pySTEPS,项目名称:pysteps,代码行数:22,代码来源:fft.py

示例5: sheardec2D

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def sheardec2D(X, shearletsystem):
    """Shearlet Decomposition function."""
    coeffs = np.zeros(shearletsystem.shearlets.shape, dtype=complex)
    Xfreq = fftshift(fft2(ifftshift(X)))
    for i in range(shearletsystem.nShearlets):
        coeffs[:, :, i] = fftshift(ifft2(ifftshift(Xfreq * np.conj(
                                   shearletsystem.shearlets[:, :, i]))))
    return coeffs.real 
开发者ID:odlgroup,项目名称:odl,代码行数:10,代码来源:shearlab_operator.py

示例6: synthesize

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def synthesize(f_hat, axes=(0, 1)):
        """
        :param f_hat:
        :param axis:
        :return:
        """

        size = np.prod([f_hat.shape[ax] for ax in axes])
        f_hat = ifftshift(f_hat * size, axes=axes)
        f = ifft2(f_hat, axes=axes)
        return f 
开发者ID:AMLab-Amsterdam,项目名称:lie_learn,代码行数:13,代码来源:T2FFT.py

示例7: ifftd

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def ifftd(I, dims=None):

    # Compute fft
    if dims is None:
        X = ifftn(I)
    elif dims == 2:
        X = ifft2(I, axes=(0, 1))
    else:
        X = ifftn(I, axes=tuple(range(dims)))

    return X 
开发者ID:comp-imaging,项目名称:ProxImaL,代码行数:13,代码来源:utils.py

示例8: xcorr

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def xcorr(imageA, imageB):
    FimageA = _fft.fft2(imageA)
    CFimageB = _np.conj(_fft.fft2(imageB))
    return _fft.fftshift(
        _np.real(_fft.ifft2((FimageA * CFimageB)))
    ) / _np.sqrt(imageA.size) 
开发者ID:jungmannlab,项目名称:picasso,代码行数:8,代码来源:imageprocess.py

示例9: fft_convolve2d

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def fft_convolve2d(x,y):
    """ 2D convolution, using FFT"""
    fr = fft2(x)
    fr2 = fft2(y)
    cc = np.real(ifft2(fr*fr2))
    cc = fftshift(cc)
    return cc 
开发者ID:ver228,项目名称:tierpsy-tracker,代码行数:9,代码来源:helper.py

示例10: fft_convolve2d

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def fft_convolve2d(x,y):
    """
    2D convolution, using FFT
    """
    fr = fft2(x)
    fr2 = fft2(np.flipud(np.fliplr(y)))
    m,n = fr.shape
    cc = np.real(ifft2(fr*fr2))
    cc = np.roll(cc, - int(m / 2) + 1, axis=0)
    cc = np.roll(cc, - int(n / 2) + 1, axis=1)
    return cc 
开发者ID:thearn,项目名称:game-of-life,代码行数:13,代码来源:lib.py

示例11: shearrec2D

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def shearrec2D(coeffs, shearletsystem):
    """Shearlet Recovery function."""
    X = np.zeros(coeffs.shape[:2], dtype=complex)
    for i in range(shearletsystem.nShearlets):
        X = X + fftshift(fft2(
            ifftshift(coeffs[:, :, i]))) * shearletsystem.shearlets[:, :, i]
    return (fftshift(ifft2(ifftshift((
            X / shearletsystem.dualFrameWeights))))).real 
开发者ID:odlgroup,项目名称:odl,代码行数:10,代码来源:shearlab_operator.py

示例12: sheardecadjoint2D

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def sheardecadjoint2D(coeffs, shearletsystem):
    """Shearlet Decomposition adjoint function."""
    X = np.zeros(coeffs.shape[:2], dtype=complex)
    for i in range(shearletsystem.nShearlets):
        X = X + fftshift(fft2(
            ifftshift(coeffs[:, :, i]))) * np.conj(
            shearletsystem.shearlets[:, :, i])
    return (fftshift(ifft2(ifftshift(
            X / shearletsystem.dualFrameWeights)))).real 
开发者ID:odlgroup,项目名称:odl,代码行数:11,代码来源:shearlab_operator.py

示例13: shearrecadjoint2D

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def shearrecadjoint2D(X, shearletsystem):
    """Shearlet Recovery adjoint function."""
    coeffs = np.zeros(shearletsystem.shearlets.shape, dtype=complex)
    Xfreq = fftshift(fft2(ifftshift(X)))
    for i in range(shearletsystem.nShearlets):
        coeffs[:, :, i] = fftshift(ifft2(ifftshift(
            Xfreq * shearletsystem.shearlets[:, :, i])))
    return coeffs.real 
开发者ID:odlgroup,项目名称:odl,代码行数:10,代码来源:shearlab_operator.py

示例14: gs

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def gs(idata,itera=10, ia=None):
    """Gerchberg-Saxton algorithm to calculate DOEs
    
    Calculates the phase distribution in a object plane to obtain an 
    specific amplitude distribution in the target plane. It uses a 
    FFT to calculate the field propagation.
    The wavefront at the DOE plane is assumed as a plane wave.
    
    **ARGUMENTS:**
    
        ========== ========================================================
        idata      numpy array containing the target amplitude distribution 
        itera      Maximum number of iterations
        ia         Illumination amplitude at the hologram plane if not given
                   it is assumed to be a constant amplitude with a value
                   of 1. If given it should be an array with the same shape
                   of idata
        ========== ========================================================
    """
    
    if ia==None:
        inpa=ones(idata.shape)
    else:
        inpa=ia
    
    assert idata.shape==inpa.shape, "ia and idata must have the same dimensions"
    
    fdata=fftshift(fft2(ifftshift(idata)))
    e=1000
    ea=1000
    
    for i in range (itera):
        fdata=exp(1.j*angle(fdata))*inpa
        
        rdata=ifftshift(ifft2(fftshift(fdata)))
        e= (abs(rdata)-idata).std()
        if e>ea: 
            break
        ea=e
        rdata=exp(1.j*angle(rdata))*(idata)
        fdata=fftshift(fft2(ifftshift(rdata)))        
    
    fdata=exp(1.j*angle(fdata))
    return fdata*inpa 
开发者ID:cihologramas,项目名称:pyoptools,代码行数:46,代码来源:gs.py

示例15: gs_mod

# 需要导入模块: from numpy import fft [as 别名]
# 或者: from numpy.fft import ifft2 [as 别名]
def gs_mod(idata,itera=10,osize=256):
    """Modiffied Gerchberg-Saxton algorithm to calculate DOEs
    
    Calculates the phase distribution in a object plane to obtain an 
    specific amplitude distribution in the target plane. It uses a 
    FFT to calculate the field propagation.
    The wavefront at the DOE plane is assumed as a plane wave.
    This algorithm leaves a window around the image plane to allow the 
    noise to move there. It only optimises the center of the image.
    
    **ARGUMENTS:**
    
        ========== ======================================================
        idata      numpy array containing the target amplitude distribution 
        itera      Maximum number of iterations
        osize      Size of the center of the image to be optimized
                   It should be smaller than the image itself.
        ========== ======================================================
    """
    M,N=idata.shape
    cut=osize//2
    
    
    zone=zeros_like(idata)
    zone[M/2-cut:M/2+cut,N/2-cut:N/2+cut]=1
    zone=zone.astype(bool)

    mask=exp(2.j*pi*random(idata.shape))
    mask[zone]=0
    
    #~ imshow(abs(mask)),colorbar()
    
    fdata=fftshift(fft2(ifftshift(idata+mask))) #Nota, colocar esta mascara es muy importante, por que si no  no converge tan rapido
    
    e=1000
    ea=1000
    for i in range (itera):
        fdata=exp(1.j*angle(fdata))

        rdata=ifftshift(ifft2(fftshift(fdata)))
        #~ e= (abs(rdata[zone])-idata[zone]).std()
        #~ if e>ea: 
           #~ 
            #~ break
        ea=e
        rdata[zone]=exp(1.j*angle(rdata[zone]))*(idata[zone])        
        fdata=fftshift(fft2(ifftshift(rdata)))   
    fdata=exp(1.j*angle(fdata))
    return fdata 
开发者ID:cihologramas,项目名称:pyoptools,代码行数:51,代码来源:gs.py


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