unibas-gravis / scalismo-faces

Scalable Image Analysis and Shape Modelling: Module to work with 2d images, with a focus on face images
Apache License 2.0
118 stars 27 forks source link

CorrespondenceMoMoRenderer #97

Closed andreas-schneider closed 6 years ago

andreas-schneider commented 6 years ago

MoMoRendrer for correspondence images. Separates rasterization and shading which allows to cache rasterization.

A correspondence image allows to create a mapping between the pixels and the mesh. The renderCorrespondenceImage function returns a PixelImage containing TriangleFragments, which contains the TriangleId and the BarycentricCoordinates specifying the exact location on a TriangleMesh.

Features:

We have this functionality without backface culling in the parametric-face-image-generator-project, but I think the Correspondence MoMoRenderer belongs into scalismo-faces.

What do you think?

Code example to create a color coded correspondence image:

  val model = ???
  val correspondenceRenderer = CorrespondenceMoMoRenderer(model).cached(5)

  val param = RenderParameter.defaultSquare
    .withMoMo(MoMoInstance.zero(model, new URI("model")))

  val renderer = CorrespondenceColorImageRenderer(correspondenceRenderer, RGBA.BlackTransparent)
  val colorCodedCorrespondence = renderer.renderImage(param)

  val depthRenderer = DepthMapRenderer(correspondenceRenderer, RGBA.BlackTransparent)
  val depthImage = depthRenderer.renderImage(param)

colorcodedcorrespondenceimage depthimage