Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2016 University of Basel, Graphics and Vision Research Group
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
package scalismo.ui.model
import breeze.linalg.DenseVector
import scalismo.common.interpolation.NearestNeighborInterpolator3D
import scalismo.common.{DiscreteDomain, UnstructuredPointsDomain}
import scalismo.geometry.{_3D, EuclideanVector, Point}
import scalismo.statisticalmodel.{DiscreteLowRankGaussianProcess, LowRankGaussianProcess}
// This used to be a case class, but since it is extended by the discrete version, it can no longer be.
// Therefore, the copy methods have to be defined manually.
class LowRankGpPointTransformation protected (val gp: LowRankGaussianProcess[_3D, EuclideanVector[_3D]],
val coefficients: DenseVector[Double])
extends PointTransformation {
private lazy val vectorField = gp.instance(coefficients)
override def apply(point: Point[_3D]): Point[_3D] = {
point + vectorField(point)
}
def copy(coefficients: DenseVector[Double]): LowRankGpPointTransformation =
new LowRankGpPointTransformation(gp, coefficients)
}
object LowRankGpPointTransformation {
def apply(gp: LowRankGaussianProcess[_3D, EuclideanVector[_3D]],
coefficients: DenseVector[Double]): LowRankGpPointTransformation =
new LowRankGpPointTransformation(gp, coefficients)
def apply(gp: LowRankGaussianProcess[_3D, EuclideanVector[_3D]]): LowRankGpPointTransformation =
apply(gp, DenseVector.zeros[Double](gp.rank))
}
class DiscreteLowRankGpPointTransformation private (
val dgp: DiscreteLowRankGaussianProcess[_3D, UnstructuredPointsDomain, EuclideanVector[_3D]],
gp: LowRankGaussianProcess[_3D, EuclideanVector[_3D]],
coefficients: DenseVector[Double]
) extends LowRankGpPointTransformation(gp, coefficients) {
protected def this(dgp: DiscreteLowRankGaussianProcess[_3D, UnstructuredPointsDomain, EuclideanVector[_3D]],
coefficients: DenseVector[Double]) = {
this(dgp, dgp.interpolate(NearestNeighborInterpolator3D()), coefficients)
}
// no need to re-interpolate if the gp didn't change
override def copy(coefficients: DenseVector[Double]): DiscreteLowRankGpPointTransformation =
new DiscreteLowRankGpPointTransformation(dgp, gp, coefficients)
}
object DiscreteLowRankGpPointTransformation {
def apply(
dgp: DiscreteLowRankGaussianProcess[_3D, UnstructuredPointsDomain, EuclideanVector[_3D]]
): DiscreteLowRankGpPointTransformation = apply(dgp, DenseVector.zeros[Double](dgp.rank))
def apply(dgp: DiscreteLowRankGaussianProcess[_3D, UnstructuredPointsDomain, EuclideanVector[_3D]],
coefficients: DenseVector[Double]): DiscreteLowRankGpPointTransformation =
new DiscreteLowRankGpPointTransformation(dgp, coefficients)
}