def __init__(self,imfilename,flatfilename='',flatdata=[]): self._Image,self._imageData=self.parseImage2(imfilename) if flatfilename!='': self._flatImage,flatdata=self.parseImage2(flatfilename) del(self._flatImage) if len(flatdata)==len(self._imageData): self._imageData=arrlog(array(flatdata)/self._imageData) self._imageMask=arrabs(array(self._imageData))>-1 self._opts={} self._opts['readMode']=1 # 0 is raw, 1 mask-values, 2 masked image self._opts['usingMat']=0 self._opts['maskMode']=0 # 0 default, -1 values under thresh, 1 values overthresh self._impResults={}
def matchImage(self,otherImage,toFlip=True): # Does a correlation between two images if toFlip: tData=fliplr(otherImage._imageData) else: tData=otherImage._imageData tempData=ifftshift(abs(ifft2(fft2(self._imageData)*fft2(tData).conj()))) del(tData) wArg=tempData.argmax() xOff=(wArg % tempData.shape[1]) yOff=round((wArg-xOff)/tempData.shape[1]) # find vector from center xOff-=tempData.shape[1]/2.0 yOff-=tempData.shape[0]/2.0 self.matchedPos=(xOff,yOff) self._impResults['Maximum Correlation']=(xOff,yOff) return arrlog(tempData) # easier to visualize