Vous avez reçu un message "Your GitLab account has been locked ..." ? Pas d'inquiétude : lisez cet article https://docs.gricad-pages.univ-grenoble-alpes.fr/help/unlock/

Commit fcb024ba authored by Edward Andò's avatar Edward Andò
Browse files

resolves #175

parent ee68cc8a
Pipeline #48247 passed with stages
in 23 minutes and 47 seconds
......@@ -274,12 +274,12 @@ class TestFunctionDVC(unittest.TestCase):
for i in range(3):
self.assertAlmostEqual(numpy.array(returns8['transformation']["t"][i]), 0, places=1)
self.assertAlmostEqual(numpy.array(returns8['transformation']["r"][i]) - [rot, 0, 0][i], 0, places=1)
#Test for a singular PhiInit
PhiGuess = numpy.array([[1., 2, 3, 0],[2, 4, 6, 0],[3, 6, 9, 0]])
returns8 = spam.DIC.register(im, imDef, margin=10, PhiInit=PhiGuess, verbose=True, updateGradient=True)
self.assertEqual(returns8['returnStatus'], -2)
def test_registerMultiScale(self):
t = {'t': [0, 0, 0],
......@@ -292,18 +292,18 @@ class TestFunctionDVC(unittest.TestCase):
for i in range(3):
self.assertAlmostEqual(t1[c][i] - t[c][i], 0, places=1)
reg2 = spam.DIC.registerMultiscale(im, imDef, 1.1, PhiInit=numpy.eye(4), margin=8)
reg2 = spam.DIC.registerMultiscale(im, imDef, 1.1, PhiInit=numpy.eye(4), margin=[8, 8, 8])
t2 = spam.deformation.decomposePhi(reg2['Phi'])
for c in ['t', 'r']:
for i in range(3):
self.assertAlmostEqual(t2[c][i] - t[c][i], 0, places=1)
# Check transaltion example with translation guess
# Check translation example with translation guess
t = {'t': [4.0, 0, 0],
'r': [0.0, 0, 0]}
Phi = spam.deformation.computePhi(t)
imDef = spam.DIC.applyPhi(im, Phi=Phi)
reg3 = spam.DIC.registerMultiscale(im, imDef, 2, deltaPhiMin=0.00001, margin=4, PhiInit=Phi)
reg3 = spam.DIC.registerMultiscale(im, imDef, 2, deltaPhiMin=0.00001, PhiInit=Phi)
t3 = spam.deformation.decomposePhi(reg3['Phi'])
for c in ['t', 'r']:
for i in range(3):
......@@ -321,7 +321,7 @@ class TestFunctionDVC(unittest.TestCase):
for c in ['t', 'r']:
for i in range(3):
self.assertAlmostEqual(t5[c][i] - t[c][i], 0, places=1)
# Test for margin = None
reg6 = spam.DIC.registerMultiscale(im, imDef, 2, margin=None, PhiInit=spam.deformation.computePhi({'t': [5,0,0]}), PhiInitBinRatio=2, updateGradient=True)
t6 = spam.deformation.decomposePhi(reg6['Phi'])
......@@ -364,7 +364,7 @@ class TestFunctionDVC(unittest.TestCase):
# self.assertTrue(ps2["cc"]>0.9)
# for i in range(3):
# self.assertAlmostEqual(tVector[i], ps2["transformation"]["t"][i], places=4)
# Test for imagette2.shape >= imagette1.shape
ps2 = spam.DIC.pixelSearch(imDef, im[subVolSlice1].copy(),
searchCentre=p,
......
......@@ -621,17 +621,27 @@ def registerMultiscale( im1, im2, binMax, PhiInit=None, PhiInitBinRatio=1.0, mar
im1b = im1
im2b = im2
# Automatically calculate margin if none is passed
# Detect default case and calculate maring necessary for a 45deg rotation with no displacement
if margin is None:
marginB = None
marginB = [1+int(0.1 * max(im1b.shape))] * 3
elif type(margin) == list:
marginB = (numpy.array(margin)//binLevel).tolist()
else:
marginB = margin//binLevel
# Make sure margin is an int
margin = int(margin)
margin = [margin] * 3
marginB = (numpy.array(margin)//binLevel).tolist()
reg = spam.DIC.register(im1b, im2b, PhiInit=reg['Phi'], PhiInitBinRatio=2.0,
margin=marginB,
maxIterations=maxIterations, deltaPhiMin=deltaPhiMin,
updateGradient=updateGradient,
interpolationOrder=interpolationOrder, interpolator=interpolator,
verbose=verbose,
imShowProgress=imShowProgress)
margin=marginB,
maxIterations=maxIterations, deltaPhiMin=deltaPhiMin,
updateGradient=updateGradient,
interpolationOrder=interpolationOrder, interpolator=interpolator,
verbose=verbose,
imShowProgress=imShowProgress)
binLevel = int(binLevel/2)
return reg
......
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