def processOneProjection(listOfDictionnaries, projectionNumber): print('------------------------------------------------------') print('processOneProjection') projectionFiles = [] referencesFiles = [] darkFieldFiles = [] for dict in listOfDictionnaries: projectionFiles.append(dict['projections'][projectionNumber]) referencesFiles.append(dict['references'][0]) darkFieldFiles.append(dict['darkField']) print(projectionFiles) Is = spytIO.openSeq(projectionFiles) print(Is.shape) Ir = spytIO.openSeq(referencesFiles) print(Ir.shape) df = spytIO.openSeq(darkFieldFiles) print(df.shape) #Is,Ir=corr.registerImagesBetweenThemselves(Is,Ir) spytIO.save3D_Edf( Is, '/Volumes/ID17/speckle/md1097/id17/Phantoms/ThreeDimensionalPhantom/OpticalFlowMultiTomo/Is/Is_' ) spytIO.save3D_Edf( Ir, '/Volumes/ID17/speckle/md1097/id17/Phantoms/ThreeDimensionalPhantom/OpticalFlowMultiTomo/Ir/Ir_' ) toReturn = OpticalFlow.processProjectionSetWithDarkFields(Is, Ir, df) return toReturn
def run(self): for numeroProjection in self.listOfProjection: numeroProjection=int(numeroProjection) print('Processing '+str(numeroProjection)) projectionFiles = [] referencesFiles = [] darkFieldFiles = [] for dict in self.listOfDictionnaries: projectionFiles.append(dict['projections'][numeroProjection]) referencesFiles.append(dict['references'][0]) darkFieldFiles.append(dict['darkField']) print(projectionFiles) Is = spytIO.openSeq(projectionFiles) Ir = spytIO.openSeq(referencesFiles) df = spytIO.openSeq(darkFieldFiles) #Is, Ir = corr.registerImagesBetweenThemselves(Is, Ir) result = OpticalFlow.processProjectionSetWithDarkFields(Is, Ir, df) dx = result['dx'] dy = result['dy'] phi = result['phi'] phi2 = result['phi2'] phi3 = result['phi3'] textProj='%4.4d'%numeroProjection spytIO.saveEdf(dx.real, self.dxFolder + '/dx' + textProj + '.edf') spytIO.saveEdf(dy.real, self.dyFolder + '/dy' + textProj + '.edf') spytIO.saveEdf(phi.real, self.phiFolder + '/phi' + textProj + '.edf') spytIO.saveEdf(phi2.real, self.phi2Folder + '/phi2' + textProj + '.edf') spytIO.saveEdf(phi3.real, self.phi3Folder + '/phi3' + textProj + '.edf')
def processOneProjection(listOfDictionnaries,projectionNumber): print('------------------------------------------------------') print('processOneProjection') projectionFiles=[] referencesFiles=[] darkFieldFiles=[] for dict in listOfDictionnaries : projectionFiles.append(dict['projections'][projectionNumber]) referencesFiles.append(dict['references'][0]) darkFieldFiles.append(dict['darkField']) print(projectionFiles) Is=spytIO.openSeq(projectionFiles) print(Is.shape) Ir=spytIO.openSeq(referencesFiles) print(Ir.shape) df=spytIO.openSeq(darkFieldFiles) print(df.shape) #Is,Ir=corr.registerImagesBetweenThemselves(Is,Ir) toReturn=OpticalFlow.processProjectionSetWithDarkFields(Is,Ir,df) return toReturn
phi = result['phi'] phi2 = result['phi2'] phi3 = result['phi3'] gradientNorm = result['gradientNorm'] spytIO.saveEdf(dx, 'output/dx' + txtNbPoint + '.edf') spytIO.saveEdf(dy.real, 'output/dy' + txtNbPoint + '.edf') spytIO.saveEdf(phi.real, 'output/phi' + txtNbPoint + '.edf') spytIO.saveEdf(phi2.real, 'output/phiLarkinson' + txtNbPoint + '.edf') spytIO.saveEdf(phi3.real, 'output/phiKottler' + txtNbPoint + '.edf') spytIO.saveEdf(gradientNorm, 'output/gradientNorm' + txtNbPoint + '.edf') if __name__ == "__main__": IrNames = glob.glob( '/Users/embrun/Codes/specklematching/Experiments/MoucheSimapAout2017/ref/*.tif' ) IsNames = glob.glob( '/Users/embrun/Codes/specklematching/Experiments/MoucheSimapAout2017/sample/*.tif' ) Ir = spytIO.openSeq(IrNames) Is = spytIO.openSeq(IsNames) nbPointsTotal = len(Is) for nbPoints in range(1, nbPointsTotal + 1): pointsToTake = generateArrayOfRandomNumbers(nbPoints, 0, nbPointsTotal - 1) IrToTake = Ir[pointsToTake] IsToTake = Is[pointsToTake] result = processProjectionSet(IsToTake, IrToTake) saveresults(result, nbPoints)
Ir = spytIO.openImage(str(referenceFiles[0])) Is = spytIO.openImage(str(sampleFiles[0])) result = processOneProjection(Is, Ir) dx = result['dx'] dy = result['dy'] phi = result['phi'] phi2 = result['phi2'] phi3 = result['phi3'] spytIO.saveEdf(dx, saveFolder + '/dx.edf') spytIO.saveEdf(dy.real, saveFolder + '/dy.edf') spytIO.saveEdf(phi.real, saveFolder + '/phi.edf') spytIO.saveEdf(phi2.real, saveFolder + '/phi2.edf') spytIO.saveEdf(phi3.real, saveFolder + '/phi3.edf') Ir3D = spytIO.openSeq(referenceFiles) Is3D = spytIO.openSeq(sampleFiles) result = processProjectionSet(Is3D, Ir3D) dx = result['dx'] dy = result['dy'] phi = result['phi'] phi2 = result['phi2'] phi3 = result['phi3'] spytIO.saveEdf(dx, saveFolder + '/dxAllFiles.edf') spytIO.saveEdf(dy.real, saveFolder + '/dyAllFiles.edf') spytIO.saveEdf(phi.real, saveFolder + '/phiAllFiles.edf') spytIO.saveEdf(phi2.real, saveFolder + '/phi2AllFiles.edf') spytIO.saveEdf(phi3.real, saveFolder + '/phi3AllFiles.edf') #offsett=corr.registerRefAndSample(Ir,Is,1000)