Commit f7252166 authored by Betoule Marc's avatar Betoule Marc
Browse files

Merge branch 'master' of gitorious.org:pipelet/pipelet

parents 715be7a0 5601df0c
......@@ -6,8 +6,8 @@ import os.path as op
import logging
import sys
S = """
first->second->fourth
third->fourth
mkgauss->convol;
fftimg->convol;
"""
#T.connect('second', ['third', 'fourth'], 'fourth')
#T.compute_hash()
......@@ -15,6 +15,8 @@ third->fourth
T = pipeline.Pipeline(S, code_dir=op.abspath('./'), prefix=op.abspath('./'))
T.to_dot('pipeline.dot')
T.push(fftimg=[1,2,3,4])
#T.push (first=["lancelot"])
print T
......
"""
"""
import pylab
load_param("fftimg", globals(), ["x_size", "y_size"])
img = seg_input['fftimg']
fft_img = glob_seg("fftimg", "fft_%d.dat"%img)[0]
fft_filter = glob_seg("mkgauss", "fft.dat")[0]
load_products(fft_filter, globals(), ["filter"])
load_products(fft_img, globals(), ["im_fft"])
for i in range(x_size):
for j in range(y_size):
im_fft [i,j] = im_fft[i,j] * filter[i,j]
im = pylab.ifft2(im_fft).real
pylab.imshow(im)
pylab.savefig(get_data_fn("filtered_%s.png"%img))
""" Compute 2d fft.
"""
import glob
import pylab
lst_par = ["x_size", "y_size"]
lst_tag = ["x_size", "y_size"]
## set image number
if seg_input is not None:
img = seg_input.values()[0]
else:
img = 1
## get image file name
img_file = glob.glob("%d.dat"%img)[0]
## load image and make a plot
im = pylab.loadtxt(img_file)
pylab.imshow(im)
pylab.savefig(get_data_fn("%d.png"%img))
x_size = pylab.shape(im)[0]
y_size = pylab.shape(im)[1]
## compute fft
im_fft = pylab.fft2(im)
save_products(get_data_fn("fft_%d.dat"%img), globals(), ["im_fft"])
seg_output = [img]
# from PIL import Image
# for l in range(4):
# im = Image.open("%d.png"%(l+1))
# im = im.convert ("L", colors=2048)
# im = im.convert("P", palette=Image.ADAPTIVE)
# #imshow(im)
# pix = im.load()
# new = zeros((256,256))
# for y in range(256):
# for x in range(256):
# new[x,y] = pix[x,y]
# #imshow(new)
# savetxt("%d.dat"%(l+1), new)
""" Make a Gaussian Fourier filter
The Gaussian shape is set by the fwhm parameter (full width half height).
The amplitude is set to unity by default.
"""
lst_par = ["fwhm" , "x_size", "y_size", "a"]
lst_tag = ["fwhm"]
import pylab
## Image dimension
x_size = 256
y_size = 256
## Gaussian full width half height
fwhm = 10
## make a gaussian pattern
im = pylab.zeros((x_size,y_size))
center_x = x_size/2
center_y = y_size/2
a = 1
fact = - pylab.log(2) / (0.25 * fwhm * fwhm)
for i in range(x_size):
for j in range(y_size):
dist = ((i-center_x)**2) + ((j-center_y)**2)
im[i,j] = a*pylab.exp(dist*fact)
for i in range(center_x, center_x+x_size):
for j in range(center_y, center_y+y_size/2):
c = im[i%x_size,j%x_size]
im[i%x_size,j%x_size] = im[i-center_x, j-center_y]
im[i-center_x, j-center_y] = c
## plot it
pylab.imshow(im)
pylab.savefig(get_data_fn("gaussian_pattern.png"))
## compute its fft
filter = pylab.fft2(im)
## save it to disk
save_products(get_data_fn("fft.dat"), globals(), ["filter"])
seg_output = [fwhm]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment