Commit 369976f5 authored by Gustavo Pinzon's avatar Gustavo Pinzon
Browse files

The gradient can be updated in the grain registration inside ddic. Before the...

The gradient can be updated in the grain registration inside ddic. Before the pixelSearch, F is applied for better results. The output of pixelSearch is checked for nan
parent 71a8ade3
Pipeline #47666 failed with stages
in 12 minutes and 39 seconds
......@@ -396,8 +396,13 @@ if mpiRank == boss or not mpi:
# point in im2 that we are searching around
searchCentre = (numpy.array(imagette2.shape, dtype='<f4') - 1) / 2.0 + labelDisplacementInt - middleOfSearchRange
#searchCentre = (numpy.array(imagette2.shape, dtype='<f4') - 1) / 2.0
# 2020-07-05 try applying F to im1 this is expected to help with pixel searching
PhiNoDisp = PhiField[label].copy()
PhiNoDisp[0:3,-1] = 0.0
imagette1def = spam.DIC.applyPhi(imagette1, PhiNoDisp)
pixelSearchReturns = spam.DIC.correlate.pixelSearch(imagette1,
pixelSearchReturns = spam.DIC.correlate.pixelSearch(imagette1def,
imagette2,
searchCentre = searchCentre,
searchRange = searchRangeForThisLabel)
......@@ -405,18 +410,23 @@ if mpiRank == boss or not mpi:
#print(pixelSearchReturns['transformation']['t'])
#print(pixelSearchReturns['cc'], "\n\n")
# 2020-01-21 EA: Add displacements back in
PhiField[label, 0:3, 3] = pixelSearchReturns['transformation']['t'] + labelDisplacementInt
# 2020-07-30 GP: Check the pixelSearch results for NaN
if any(numpy.isnan(pixelSearchReturns['transformation']['t'])) == True:
print("spam-ddic: PixelSearch result is NaN, setting it to 0. Check the initial guess.")
PhiField[label, 0:3, 3] = labelDisplacementInt
else:
PhiField[label, 0:3, 3] = pixelSearchReturns['transformation']['t'] + labelDisplacementInt
PSCC[label] = pixelSearchReturns['cc']
if args.GRID_POINT:
labelDisplacementInt = numpy.round(PhiField[label][0:3, -1])
slicette2 = (slice(max(int(boundingBoxes[label][0] - args.GRID_POINT_MARGIN - max(labelDilateCurrent, 0) + labelDisplacementInt[0]), 0),
min(int(boundingBoxes[label][1] + args.GRID_POINT_MARGIN + max(labelDilateCurrent, 0) + labelDisplacementInt[0] + 1), im1.shape[0])),
slice(max(int(boundingBoxes[label][2] - args.GRID_POINT_MARGIN - max(labelDilateCurrent, 0) + labelDisplacementInt[1]), 0),
min(int(boundingBoxes[label][3] + args.GRID_POINT_MARGIN + max(labelDilateCurrent, 0) + labelDisplacementInt[1] + 1), im1.shape[1])),
slice(max(int(boundingBoxes[label][4] - args.GRID_POINT_MARGIN - max(labelDilateCurrent, 0) + labelDisplacementInt[2]), 0),
min(int(boundingBoxes[label][5] + args.GRID_POINT_MARGIN + max(labelDilateCurrent, 0) + labelDisplacementInt[2] + 1), im1.shape[2])))
min(int(boundingBoxes[label][1] + args.GRID_POINT_MARGIN + max(labelDilateCurrent, 0) + labelDisplacementInt[0] + 1), im1.shape[0])),
slice(max(int(boundingBoxes[label][2] - args.GRID_POINT_MARGIN - max(labelDilateCurrent, 0) + labelDisplacementInt[1]), 0),
min(int(boundingBoxes[label][3] + args.GRID_POINT_MARGIN + max(labelDilateCurrent, 0) + labelDisplacementInt[1] + 1), im1.shape[1])),
slice(max(int(boundingBoxes[label][4] - args.GRID_POINT_MARGIN - max(labelDilateCurrent, 0) + labelDisplacementInt[2]), 0),
min(int(boundingBoxes[label][5] + args.GRID_POINT_MARGIN + max(labelDilateCurrent, 0) + labelDisplacementInt[2] + 1), im1.shape[2])))
imagette2imagette1sizeDiff = numpy.array(im2[slicette2].shape) - numpy.array(imagette1.shape)
......@@ -438,6 +448,7 @@ if mpiRank == boss or not mpi:
maxIterations=args.GRID_POINT_MAX_ITERATIONS,
deltaPhiMin=args.GRID_POINT_MIN_PHI_CHANGE,
interpolationOrder=args.GRID_POINT_INTERPOLATION_ORDER,
updateGradient=args.GRID_POINT_REG_UPDATE,
verbose=False,
imShowProgress=None)
writeReturns = True
......@@ -455,7 +466,8 @@ if mpiRank == boss or not mpi:
'interpolationOrder': args.GRID_POINT_INTERPOLATION_ORDER,
'labelDisplacementInt': labelDisplacementInt,
'writeReturns': writeReturns,
'labelDilate': labelDilateCurrent
'labelDilate': labelDilateCurrent,
'updateGradient': updateGradient=args.GRID_POINT_REG_UPDATE
}
# print("\t\tBoss: sending label {} to worker {}".format(label, worker))
......
......@@ -588,6 +588,12 @@ def ddicParser(parser):
default=1,
dest='GRID_POINT_INTERPOLATION_ORDER',
help="Interpolation order for grid-point registration. Default = 3")
parser.add_argument('-gpup',
'--grid-point-registration-update',
action="store_true",
dest='GRID_POINT_REG_UPDATE',
help='Update gradient in grain registration? More computation time but more robust and possibly fewer iterations. Default = False')
parser.add_argument('-od',
'--out-dir',
......
Supports Markdown
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