def add_shape(self, f):
		#Create shape
		S = Shape(f, self.R, self.SHAPE_R)
	
		#Add to shape list
		S.shape_num = len(self.shape_list)
		self.shape_list.append(S)
		
		row = []
		for k in range(len(self.shape_list)):
			T = self.shape_list[k]
			ift = real(ipfft(pft_mult(pft_rotate(S.pft, 2.*pi/6.), T.pft), 2*self.SHAPE_R+1,2*self.SHAPE_R+1))
			Spad = imrotate(cpad(S.indicator, array([2*self.SHAPE_R+1,2*self.SHAPE_R+1])), 360./6.)
			Tpad = cpad(T.indicator, array([2*self.SHAPE_R+1,2*self.SHAPE_R+1]))
			pind = real(fftconvolve(Spad, Tpad, mode='same'))
			imshow(pind)
			imshow(ift)
			obst = to_ind(pind, 0.001)
			imshow(obst)
			cutoff = best_cutoff(ift, obst, S.radius + T.radius)
			print cutoff
			imshow(to_ind(ift, cutoff))
			row.append(cutoff * self.tarea)
		self.cutoff_matrix.append(row)

		return S
示例#2
0
from misc import *

import fourier_obstacle as obstacle
from polar import ipfft, pft_mult
import os
import pickle

db = obstacle.ShapeSet(32, 256)
db.add_shape(load_img("shape3.png"))
db.add_shape(load_img("shape4.png"))


A = db.shape_list[0]
B = db.shape_list[1]

pconv = ipfft(pft_mult(A.pft, B.pft), 513, 513)
imsave("test1.png",  pconv)
imshow(pconv)

#Contstruct sampled convolution field
sconv = zeros((513, 513))
for i in range(513):
	for j in range(513):
		x = 257. - i
		y = 257. - j
		sconv[i, j] = db.potential(A, B, array([0., 0.]), array([x, y]), 0., pi/6.)
		print x,y, sconv[i,j]
		
imsave("test2.png", sconv)
imshow(sconv)