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 9de391fe authored by Edward Andò's avatar Edward Andò
Browse files

improvements in ddic and ZYX view in register()

parent 50141258
Pipeline #47868 failed with stages
in 12 minutes and 47 seconds
......@@ -339,7 +339,7 @@ if mpiRank == boss or not mpi:
worker = numpy.where(numpy.logical_not(workersActive))[0][0]
# Get the next label off the queue
label, labelDilateCurrent = q.get()
if args.DEBUG: print("\nWorking on label:", label, "\n")
if args.DEBUG: print("\n\n\nWorking on label:", label, "\n")
grainOK = False
getLabel = ltk.getLabel(lab1, label,
extractCube=False,
......@@ -347,7 +347,8 @@ if mpiRank == boss or not mpi:
centresOfMass=centresOfMass,
margin=labelDilateCurrent + args.LABEL_CORRELATE_MARGIN,
maskOtherLabels=args.MASK,
labelDilate=labelDilateCurrent)
labelDilate=labelDilateCurrent,
labelDilateMaskOtherLabels=True)
# In case the label is missing or the Phi is duff
if getLabel is None or not numpy.all(numpy.isfinite(PhiField[label])):
......
......@@ -32,7 +32,7 @@ import progressbar
#numpy.set_printoptions(precision=3, suppress=True)
def register(im1, im2, im1mask=None, PhiInit=None, PhiRigid=False, PhiInitBinRatio=1.0, margin=None, maxIterations=25, deltaPhiMin=0.001, updateGradient=False, interpolationOrder=1, interpolator='python', verbose=False, imShowProgress=None, imShowProgressNewFig=False):
def register(im1, im2, im1mask=None, PhiInit=None, PhiRigid=False, PhiInitBinRatio=1.0, margin=None, maxIterations=25, deltaPhiMin=0.001, updateGradient=False, interpolationOrder=1, interpolator='python', verbose=False, imShowProgress=False, imShowProgressNewFig=False):
"""
Perform subpixel image correlation between im1 and im2.
......@@ -96,11 +96,12 @@ def register(im1, im2, im1mask=None, PhiInit=None, PhiRigid=False, PhiInitBinRat
Default = 'python'. 'C' is also an option
verbose : bool, optional
Get to know what the function is really thinking, recommended for debugging only. Default = False
Get to know what the function is really thinking, recommended for debugging only.
Default = False
imShowProgress : String, optional (default = None)
imShowProgress : Bool, optional
Pop up a window showing a ``imShowProgress`` slice of the image differences (im1-im2) as im1 is progressively deformed.
Accepted options are "Z", "Y" and "X" -- the slicing direction.
Default = False
imShowProgressNewFig : bool, optional (defaul = False)
Make a new plt.figure for each iteration, useful for examples gallery
......@@ -227,33 +228,33 @@ def register(im1, im2, im1mask=None, PhiInit=None, PhiRigid=False, PhiInitBinRat
# print( "\tcorrelate.register(): realMargin is:", realMargin)
# If live plot is asked for, initialise canvas
if imShowProgress is not None:
if imShowProgress:
import matplotlib.pyplot as plt
# Plot ranges for signed residual
vmin = -im1crop.max()
vmax = im1crop.max()
if not imShowProgressNewFig:
if imShowProgress == "Z" or imShowProgress == "z":
plt.subplot(1,3,1)
plt.axis([im1crop.shape[2], 0, im1crop.shape[1], 0])
plt.subplot(1,3,2)
plt.axis([im1crop.shape[2], 0, im1crop.shape[1], 0])
plt.subplot(1,3,3)
plt.axis([im1crop.shape[2], 0, im1crop.shape[1], 0])
if imShowProgress == "Y" or imShowProgress == "y":
plt.subplot(1,3,1)
plt.axis([im1crop.shape[2], 0, im1crop.shape[0], 0])
plt.subplot(1,3,2)
plt.axis([im1crop.shape[2], 0, im1crop.shape[0], 0])
plt.subplot(1,3,3)
plt.axis([im1crop.shape[2], 0, im1crop.shape[0], 0])
if imShowProgress == "X" or imShowProgress == "x":
plt.subplot(1,3,1)
plt.axis([im1crop.shape[1], 0, im1crop.shape[0], 0])
plt.subplot(1,3,2)
plt.axis([im1crop.shape[1], 0, im1crop.shape[0], 0])
plt.subplot(1,3,3)
plt.axis([im1crop.shape[1], 0, im1crop.shape[0], 0])
#if imShowProgress == "Z" or imShowProgress == "z":
plt.subplot(3,3,1)
plt.axis([im1crop.shape[2], 0, im1crop.shape[1], 0])
plt.subplot(3,3,2)
plt.axis([im1crop.shape[2], 0, im1crop.shape[1], 0])
plt.subplot(3,3,3)
plt.axis([im1crop.shape[2], 0, im1crop.shape[1], 0])
#if imShowProgress == "Y" or imShowProgress == "y":
plt.subplot(3,3,4)
plt.axis([im1crop.shape[2], 0, im1crop.shape[0], 0])
plt.subplot(3,3,5)
plt.axis([im1crop.shape[2], 0, im1crop.shape[0], 0])
plt.subplot(3,3,6)
plt.axis([im1crop.shape[2], 0, im1crop.shape[0], 0])
#if imShowProgress == "X" or imShowProgress == "x":
plt.subplot(3,3,7)
plt.axis([im1crop.shape[1], 0, im1crop.shape[0], 0])
plt.subplot(3,3,8)
plt.axis([im1crop.shape[1], 0, im1crop.shape[0], 0])
plt.subplot(3,3,9)
plt.axis([im1crop.shape[1], 0, im1crop.shape[0], 0])
plt.ion()
# Numerical value for normalising the error
......@@ -470,34 +471,34 @@ def register(im1, im2, im1mask=None, PhiInit=None, PhiRigid=False, PhiInitBinRat
returnStatus = -3
break
if imShowProgress is not None:
if imShowProgress == "Z" or imShowProgress == "z":
if imShowProgressNewFig: plt.figure()
else: plt.clf()
plt.subplot(1,3,1)
plt.imshow(im1crop[im1crop.shape[0] // 2, :, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(1,3,2)
plt.imshow(im2def[crop2][im1crop.shape[0] // 2, :, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(1,3,3)
plt.imshow(numpy.subtract(im1crop, im2def[crop2])[im1crop.shape[0] // 2, :, :], cmap='coolwarm', vmin=vmin, vmax=vmax)
if imShowProgress == "Y" or imShowProgress == "y":
if imShowProgressNewFig: plt.figure()
else: plt.clf()
plt.subplot(1,3,1)
plt.imshow(im1crop[:, im1crop.shape[1] // 2, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(1,3,2)
plt.imshow(im2def[crop2][:, im1crop.shape[1] // 2, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(1,3,3)
plt.imshow(numpy.subtract(im1crop, im2def[crop2])[:, im1crop.shape[1] // 2, :], cmap='coolwarm', vmin=vmin, vmax=vmax)
if imShowProgress == "X" or imShowProgress == "x":
if imShowProgressNewFig: plt.figure()
else: plt.clf()
plt.subplot(1,3,1)
plt.imshow(im1crop[:, :, im1crop.shape[2] // 2], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(1,3,2)
plt.imshow(im2def[crop2][:, :, im1crop.shape[2] // 2], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(1,3,3)
plt.imshow(numpy.subtract(im1crop, im2def[crop2])[:, :, im1crop.shape[2] // 2], cmap='coolwarm', vmin=vmin, vmax=vmax)
if imShowProgress:
#if imShowProgress == "Z" or imShowProgress == "z":
if imShowProgressNewFig: plt.figure()
else: plt.clf()
plt.subplot(3,3,1)
plt.imshow(im1crop[im1crop.shape[0] // 2, :, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(3,3,2)
plt.imshow(im2def[crop2][im1crop.shape[0] // 2, :, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(3,3,3)
plt.imshow(numpy.subtract(im1crop, im2def[crop2])[im1crop.shape[0] // 2, :, :], cmap='coolwarm', vmin=vmin, vmax=vmax)
#if imShowProgress == "Y" or imShowProgress == "y":
#if imShowProgressNewFig: plt.figure()
#else: plt.clf()
plt.subplot(3,3,4)
plt.imshow(im1crop[:, im1crop.shape[1] // 2, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(3,3,5)
plt.imshow(im2def[crop2][:, im1crop.shape[1] // 2, :], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(3,3,6)
plt.imshow(numpy.subtract(im1crop, im2def[crop2])[:, im1crop.shape[1] // 2, :], cmap='coolwarm', vmin=vmin, vmax=vmax)
#if imShowProgress == "X" or imShowProgress == "x":
#if imShowProgressNewFig: plt.figure()
#else: plt.clf()
plt.subplot(3,3,7)
plt.imshow(im1crop[:, :, im1crop.shape[2] // 2], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(3,3,8)
plt.imshow(im2def[crop2][:, :, im1crop.shape[2] // 2], cmap='Greys_r', vmin=0, vmax=vmax)
plt.subplot(3,3,9)
plt.imshow(numpy.subtract(im1crop, im2def[crop2])[:, :, im1crop.shape[2] // 2], cmap='coolwarm', vmin=vmin, vmax=vmax)
plt.title('Iteration Number = {}'.format(iterations))
plt.pause(0.5)
......
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