How to apply coefficients from low resolution non-rigid icp to high resolution mesh

67 views
Skip to first unread message

Maia R.

unread,
Mar 11, 2021, 5:20:34 PM3/11/21
to scalismo
Hi,   
I am stuck on how to apply the coefficients from low res pdm to high res mesh. 
Here are what I've done so far:
================================
// I have a high resolution targetMesh:
1) Compute high resolution posterior model (with landmarks) and get highResPosteriorModel
2) Decimate the reference mesh of highResPosteriorModel and get a low res model:
val decimatedMesh = highResPosteriorModel.reference.operations.decimate(numberOfTargetedVertices)
val lowResModel = highResPosteriorModel.newReference(decimatedMesh, TriangleMeshInterpolator3D())
3) Get uniform points from the low res reference (as in https://scalismo.org/docs/tutorials/tutorial11):
val sampler = UniformMeshSampler3D(lowResModel.reference, numberOfPoints = 5000)
val points : Seq[Point[_3D]] = sampler.sample.map(pointWithProbability => pointWithProbability._1)
val ptIds = points.map(point => lowResModel.reference.pointSet.findClosestPoint(point).id)
4) Non rigid icp with this low res model (output the mean and the posterior model). I changed the fitModel function in https://scalismo.org/docs/tutorials/tutorial11 so that it outputs
the posterior.mean and the posterior model as well:
val finalFitAndPosteriorModel = nonrigidICP(lowResModel.mean, highResolutionTargetMesh, ptIds, 20)
val finalFit = finalFitAndPosteriorModel._1
val lastLowResPosteriorModel = finalFitAndPosteriorModel._2

5) Get the final coefficients of the mean of the low res posterior model:
val meanLowResCoeffs: DenseVector[Double] = lastLowResPosteriorModel.coefficients(lastLowResPosteriorModel.mean)
6) Here is where I am stuck as I don't know how to apply those coefficients to the high resolution mesh (either mean, sample or the reference)
// I tried this but I am to sure at all if this is correct
val highResMeshMean =  highResPosteriorModel.instance(meanLowResCoeffs) // The method instance needs a pdm but I don't know which one is to be used here ?

Also, in step 4, do I need to use a decimated targetMesh or keep the original high resolution mesh (highResolutionTargetMesh)?
===============================

Thank you very much for any help,
Best regards
Maia

Marcel Luethi

unread,
Mar 15, 2021, 10:55:56 AM3/15/21
to Maia R., scalismo
Hi Maia

When you call decimate on the PointDistributionModel or StatisticalMeshModel, the coefficients do not change. So you can completely freely change resolutions and you the resolution coefficients on a different resolution model. Decimating the target can be done in addition to decimating the reference. It will lead to a speedup because the closest point computations are  a bit faster for low-resolution meshes.

Best regards,
Marcel

--
You received this message because you are subscribed to the Google Groups "scalismo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalismo+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalismo/3bb9af8f-5ec1-427f-b554-4ae7a38e0ee6n%40googlegroups.com.

Maia R.

unread,
Mar 15, 2021, 11:45:31 AM3/15/21
to scalismo
Hi Marcel,
Thank you for the explanation.

So is it correct to use those coefficients as below to get an instance of the pdm ?
=====
val highResMeanMesh =  originalPDM.instance(meanLowResCoeffs)  (here I want to get the high res mean mesh from the coefficients computed with the low res approach)
where originalPDM is the one with the high res reference
and meanLowResCoeffs is the coefficients from any instance of the low res pdm (mean or sample(), here they are from the mean)
=====

Sorry to bother you with that as I was unsure about the concept behind. I was asking to  myself if I needed to create a new gp from the low res, interpolate, create a new low rank gp before applying to the high res.

Thank you very much,
Best regards,
Maia

Marcel Luethi

unread,
Mar 18, 2021, 3:30:31 AM3/18/21
to Maia R., scalismo
Dear Maia,

Yes, this is correct. You can use the same coefficients. You can also easily verify this visually, by visualizing the corresponding samples in ScalismoUI.

Best regards,
Marcel

Maia R.

unread,
Mar 18, 2021, 10:02:38 AM3/18/21
to scalismo
Hi Marcel,
Thank you A LOT for your kind direction. 
I applied the low res + coarse to fine approach as in https://scalismo.org/docs/tutorials/tutorial12, decimating the reference mesh from 70000 points to 10000 points, I got very good results within almost 2 min instead of 44 hours !!! (I use a multiscale kernel which gave me 400 coefficients).
Best regards,
Maia

Marcel Luethi

unread,
Mar 19, 2021, 3:32:28 AM3/19/21
to Maia R., scalismo
Hi Maia

This is great news, Congratulations!

Choosing the resolution of the mesh to avoid excessive computations is the key to making things fast. If performance is crucial, a typical strategy is to start with a very coarse mesh, and only for the last few iterations to use a mesh of higher resolution, For simple shapes, you can bring down the time for good registrations to mere seconds with this approach.

Best regards,
Marcel

V R

unread,
Mar 19, 2021, 6:54:25 AM3/19/21
to Marcel Luethi, scalismo
Thank you very much! 
Another strategy to be used !
Best regards
Maia
Reply all
Reply to author
Forward
0 new messages