X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=itk%2FitkBSplineWeightsCalculator.txx;h=4f45019c195919246054d60d75be8649020b96ad;hb=4cfd18a5e026b6b20a4dfbdd32606b0fc18883b5;hp=d61276832cd88349dc2908c28972045f46e7fb3f;hpb=931a42358442f4ee4f314613c991c838d4b4e3b7;p=clitk.git diff --git a/itk/itkBSplineWeightsCalculator.txx b/itk/itkBSplineWeightsCalculator.txx index d612768..4f45019 100644 --- a/itk/itkBSplineWeightsCalculator.txx +++ b/itk/itkBSplineWeightsCalculator.txx @@ -1,19 +1,36 @@ +/*========================================================================= + Program: vv http://www.creatis.insa-lyon.fr/rio/vv + + Authors belong to: + - University of LYON http://www.universite-lyon.fr/ + - Léon Bérard cancer center http://www.centreleonberard.fr + - CREATIS CNRS laboratory http://www.creatis.insa-lyon.fr + + This software is distributed WITHOUT ANY WARRANTY; without even + the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + PURPOSE. See the copyright notices for more information. + + It is distributed under dual licence + + - BSD See included LICENSE.txt file + - CeCILL-B http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html +===========================================================================**/ /* ========================================================================= - + @file itkBSplineWeightsCalculator.h @author David Sarrut - Copyright (c) - * CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). + Copyright (c) + * CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or http://www.creatis.insa-lyon.fr/Public/Gdcm/License.html for details. * Léon Bérard cancer center, 28 rue Laënnec, 69373 Lyon cedex 08, France * http://www.creatis.insa-lyon.fr/rio - + This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. - + ========================================================================= */ #ifndef ITKBSPLINEWEIGHTSCALCULATOR_TXX @@ -21,7 +38,8 @@ //==================================================================== template -typename Index::IndexValueType Index2Offset(const Index & index, const Index & offsetTable) { +typename Index::IndexValueType Index2Offset(const Index & index, const Index & offsetTable) +{ long v = index[0]; for(int l=1; l::IndexValueType Index2Offset(const Index //==================================================================== template BSplineWeightsCalculator:: -BSplineWeightsCalculator() { +BSplineWeightsCalculator() +{ mWeightsAreUpToDate = false; } //==================================================================== @@ -41,7 +60,8 @@ BSplineWeightsCalculator() { //==================================================================== template void BSplineWeightsCalculator:: -SetSplineOrder(int splineOrder) { +SetSplineOrder(int splineOrder) +{ SizeType temp; for(int l=0; l void BSplineWeightsCalculator:: -SetSplineOrders(const SizeType & splineOrder) { +SetSplineOrders(const SizeType & splineOrder) +{ // Compute support size mSupportSize = 1; for(int l=0; l void BSplineWeightsCalculator:: -SetSamplingFactor(int sampling) { +SetSamplingFactor(int sampling) +{ for(int l=0; l void BSplineWeightsCalculator:: -SetSamplingFactors(const SizeType & sampling) { +SetSamplingFactors(const SizeType & sampling) +{ for(int l=0; l -typename BSplineWeightsCalculator::InitialWeightsType & +typename BSplineWeightsCalculator::InitialWeightsType & BSplineWeightsCalculator:: -GetInitialWeights(int order) { +GetInitialWeights(int order) +{ if (!mBasisFunctionCoefficientsMatrixAreUpToDate[order]) ComputeBasisFunctionCoefficientsMatrix(order); return mBasisFunctionCoefficientsMatrix[order]; } //==================================================================== //==================================================================== -template inline T factorial(T rhs) { - T lhs = (T)1; +template inline T factorial(T rhs) +{ + T lhs = (T)1; for(T x=(T)1; x<=rhs; ++x) { lhs *= x; - } + } return lhs; } //==================================================================== @@ -123,7 +147,8 @@ template inline T factorial(T rhs) { //==================================================================== template double BSplineWeightsCalculator:: -BinomialCoefficient(int i, int j) { +BinomialCoefficient(int i, int j) +{ double f = (factorial(i))/(factorial(j) * factorial(i-j)); return f; } @@ -132,7 +157,8 @@ BinomialCoefficient(int i, int j) { //==================================================================== template void BSplineWeightsCalculator:: -ComputeBasisFunctionCoefficientsMatrix(int order) { +ComputeBasisFunctionCoefficientsMatrix(int order) +{ // Compute the sxs matrix of coefficients used to build the different // polynomials. With s the support is order+1. int s = order+1; @@ -143,9 +169,9 @@ ComputeBasisFunctionCoefficientsMatrix(int order) { for(int j=0; j TCoefficientType BSplineWeightsCalculator:: -BSplineEvaluate(int order, int k, double e) { - // Evaluate a BSpline +BSplineEvaluate(int order, int k, double e) +{ + // Evaluate a BSpline int s=order+1; TCoefficientType v = 0.0; for(int p=0; p void BSplineWeightsCalculator:: -ComputeSampledWeights1D(std::vector > & w, int order, int sampling) { +ComputeSampledWeights1D(std::vector > & w, int order, int sampling) +{ int s = order+1; w.resize(s); for(int k=0; k > & w, int ord } e += offset; if (fabs(1.0-e)<=1e-6) e = 1.0; // (for even order) - if (e>=1.0) e = e-1.0; + if (e>=1.0) e = e-1.0; } } //==================================================================== @@ -201,10 +229,11 @@ ComputeSampledWeights1D(std::vector > & w, int ord //==================================================================== template void BSplineWeightsCalculator:: -ComputeSampledWeights() { +ComputeSampledWeights() +{ mWeights.resize(VDimension); // Loop over dimension to compute weights - for(int l=0; l void BSplineWeightsCalculator:: -ComputeTensorProducts() { +ComputeTensorProducts() +{ // Initial BSpline samples weights ComputeSampledWeights(); - + // tensor product memory offsets mTensorProductMemoryOffset[0] = 1; - for(int l=1; l const TCoefficientType * BSplineWeightsCalculator:: -GetFirstTensorProduct(const IndexType & index) const { +GetFirstTensorProduct(const IndexType & index) const +{ int i = Index2Offset(index, mTensorProductMemoryOffset); return &(mTensorProducts[i][0]); }