コード例 #1
0
ファイル: spatial.py プロジェクト: siddharth05/imagine
def fourierFilter(fileName,sigma,num):
    workData = getData(fileName,num)
    print 'INput sigma'
    #sigma = float(raw_input())
    fourFilter1 = ndimage.fourier_uniform(workData,sigma)
    fourFilter = ndimage.fourier_uniform(fourFilter1,sigma)
    mfSave = Image.fromarray(fourFilter)
    mfSave = mfSave.convert('L')
    mfSave.save('Fourier Filter.jpg')
    imageGUI.imdisplay('Fourier Filter.jpg','Fourier Filter',1)
コード例 #2
0
    def transform_image(dimensions, image):
        size = dimensions[0]

        image = image.copy() / 255.
        for channel in range(image.shape[2]):
            image[:, :, channel] = fftpack.ifft2(
                fourier_uniform(fftpack.fft2(image[:, :, channel]), size)).real
        return np.clip(image * 255., 0., 255.)
コード例 #3
0
 def test_fourier_uniform_complex01(self, shape, dtype, dec):
     a = numpy.zeros(shape, dtype)
     a[0, 0] = 1.0
     a = fft.fft(a, shape[0], 0)
     a = fft.fft(a, shape[1], 1)
     a = ndimage.fourier_uniform(a, [5.0, 2.5], -1, 0)
     a = fft.ifft(a, shape[1], 1)
     a = fft.ifft(a, shape[0], 0)
     assert_almost_equal(ndimage.sum(a.real), 1.0, decimal=dec)
コード例 #4
0
 def test_fourier_ellipsoid_1d_complex(self):
     # expected result of 1d ellipsoid is the same as for fourier_uniform
     for shape in [(32, ), (31, )]:
         for type_, dec in zip([numpy.complex64, numpy.complex128],
                               [5, 14]):
             x = numpy.ones(shape, dtype=type_)
             a = ndimage.fourier_ellipsoid(x, 5, -1, 0)
             b = ndimage.fourier_uniform(x, 5, -1, 0)
             assert_array_almost_equal(a, b, decimal=dec)
コード例 #5
0
ファイル: prog08.py プロジェクト: joyfish/Programas
import scipy.ndimage as ndi
import scipy.misc as misc
import matplotlib.pyplot as plt
import numpy as np

img = misc.ascent()

noisy = img + 0.09 * img.std() * np.random.random(img.shape)

fe = ndi.fourier_ellipsoid(img, 1)
fg = ndi.fourier_gaussian(img, 1)
fs = ndi.fourier_shift(img, 1)
fu = ndi.fourier_uniform(img, 1)
title = ['original', 'Noisy', 'Fourier Ellipsoid', 'Fourier Gaussian', 'Fourier Shift', 'Fourier uniform']
output = [img, noisy, fe, fg, fs, fu]
for i in range(6):
    plt.subplot(2, 3, i + 1)
    plt.imshow(np.float64(output[i]), cmap='gray')
    plt.title(title[i])
    plt.axis('off')
plt.show()
def fourier(img, size=100):
    return [
        ndimage.fourier_ellipsoid(img, size),
        ndimage.fourier_shift(img, size),
        ndimage.fourier_uniform(img, size)
    ]
コード例 #7
0
ファイル: functionSet_renew5.py プロジェクト: yingbi7460/egp
def fourier_uniform(left):
    left = ndimage.fourier_uniform(left, size=3, axis=0)
    return left
コード例 #8
0
def fourierut(f):
    f1 = ndimage.fourier_uniform(f, size=1.25)
    return (f1)
コード例 #9
0
from scipy import ndimage, misc
import numpy.fft
import matplotlib.pyplot as plt
fig, (ax1, ax2) = plt.subplots(1, 2)
plt.gray()  # show the filtered result in grayscale
ascent = misc.ascent()
input_ = numpy.fft.fft2(ascent)
result = ndimage.fourier_uniform(input_, size=20)
result = numpy.fft.ifft2(result)
ax1.imshow(ascent)
ax2.imshow(result.real)  # the imaginary part is an artifact
plt.show()