示例#1
0
def mexhatFilter(a, mexSize=1):#, trimRatio=0.9):
    """
    returned array is trimmed to remove edge
    """
    global mexhatC, mexhatC_size, mexhatCf

    a = imgFilters.evenShapeArr(a)
    from Priithon.all import F as fftw
    try:
        if mexhatC.shape != a.shape:
            raise ValueError('go to except')
        if mexhatC_size != mexSize:
            raise ValueError('go to except')
    except NameError as ValueError:
        mexhatC_size = mexSize
        shape = N.asarray(a.shape, N.int)#N.float32)
        mexhatC = F.shift(F.mexhatArr(shape, scaleHalfMax=mexhatC_size, orig=None)) # orig 0.5 pixel does not work...
        mexhatCf = fftw.rfft(mexhatC) / N.multiply.reduce( shape )

    ar = fftw.irfft( fftw.rfft(a.astype(N.float32)) * mexhatCf )
    
    #if trimRatio < 1:
    #    ar = trim3D(ar, trimRatio)
    #ar = imgFilters.maskEdgeWithValue2D(ar) # 2 pixels at the edges
    return ar
示例#2
0
def mexhatFilter(a, mexSize=1):  #, trimRatio=0.9):
    """
    returned array is trimmed to remove edge
    """
    global mexhatC, mexhatC_size, mexhatCf

    a = imgFilters.evenShapeArr(a)
    from Priithon.all import F as fftw
    try:
        if mexhatC.shape != a.shape:
            raise ValueError('go to except')
        if mexhatC_size != mexSize:
            raise ValueError('go to except')
    except NameError as ValueError:
        mexhatC_size = mexSize
        shape = N.asarray(a.shape, N.int)  #N.float32)
        mexhatC = F.shift(
            F.mexhatArr(shape, scaleHalfMax=mexhatC_size,
                        orig=None))  # orig 0.5 pixel does not work...
        mexhatCf = fftw.rfft(mexhatC) / N.multiply.reduce(shape)

    ar = fftw.irfft(fftw.rfft(a.astype(N.float32)) * mexhatCf)

    #if trimRatio < 1:
    #    ar = trim3D(ar, trimRatio)
    #ar = imgFilters.maskEdgeWithValue2D(ar) # 2 pixels at the edges
    return ar
示例#3
0
def mexhatFilter(a, mexSize=1):  #, trimRatio=0.9):
    """
    returned array is trimmed to remove edge
    """
    global mexhatC, mexhatC_size, mexhatCf

    a = imgFilters.evenShapeArr(a)
    try:  # inside package
        from ..Priithon.all import F as fftw
    except ValueError:  # Attempted relative import beyond toplevel package
        from Priithon.all import F as fftw
    #from Priithon.all import F as fftw
    try:
        if mexhatC.shape != a.shape:
            raise ValueError, 'go to except'
        if mexhatC_size != mexSize:
            raise ValueError, 'go to except'
    except NameError, ValueError:
        mexhatC_size = mexSize
        shape = N.asarray(a.shape, N.float32)
        mexhatC = F.shift(
            F.mexhatArr(shape, scaleHalfMax=mexhatC_size,
                        orig=None))  # orig 0.5 pixel does not work...
        mexhatCf = fftw.rfft(mexhatC) / N.multiply.reduce(shape)