def _maskHighPassFilter(a,zero_radius,one_radius):
        if zero_radius == 0 or zero_radius > one_radius:
                return a
        fft = ffteng.transform(a)
        fft = imagefun.swap_quadrants(fft)
        _center_mask(fft,zero_radius,one_radius)
        bfft = imagefun.swap_quadrants(fft)
        b = ffteng.itransform(bfft)
        return b
def getBeamTiltPhaseShiftCorrection(imgshape,beamtilt,Cs,wavelength,pixelsize):
		beamtilt_size = math.sqrt(beamtilt[0]*beamtilt[0]+beamtilt[1]*beamtilt[1])
		scaled_Cs_wavelength_squared = Cs * wavelength**2 / (pixelsize*imgshape[0])**3
		c = imgshape[0]/2,imgshape[1]/2
		phaseshift = numpy.fromfunction(lambda i, j: 
			2*math.pi*scaled_Cs_wavelength_squared*((i-c[0])*(i-c[0])+(j-c[1])*(j-c[1]))*((i-c[0])*beamtilt[0]+(j-c[1])*beamtilt[1]), imgshape)
		phaseshift = imagefun.swap_quadrants(phaseshift)
		#print phaseshift[c[0],:] * 180.0 / math.pi
		correction = numpy.cos(phaseshift)+numpy.sin(phaseshift)*complex(0,1)
		return correction
def getBeamTiltPhaseShiftCorrection(imgshape,beamtilt,Cs,wavelength,pixelsize):
                beamtilt_size = math.sqrt(beamtilt[0]*beamtilt[0]+beamtilt[1]*beamtilt[1])
                scaled_Cs_wavelength_squared = Cs * wavelength**2 / (pixelsize*imgshape[0])**3
                c = imgshape[0]/2,imgshape[1]/2
                phaseshift = numpy.fromfunction(lambda i, j: 
                        2*math.pi*scaled_Cs_wavelength_squared*((i-c[0])*(i-c[0])+(j-c[1])*(j-c[1]))*((i-c[0])*beamtilt[0]+(j-c[1])*beamtilt[1]), imgshape)
                phaseshift = imagefun.swap_quadrants(phaseshift)
                #print phaseshift[c[0],:] * 180.0 / math.pi
                correction = numpy.cos(phaseshift)+numpy.sin(phaseshift)*complex(0,1)
                return correction
 def swapQuadrants(self, image):
     return imagefun.swap_quadrants(image)
 def swapQuadrants(self, image):
     return imagefun.swap_quadrants(image)