/*========================================================================= 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). 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 #define ITKBSPLINEWEIGHTSCALCULATOR_TXX //==================================================================== template typename Index::IndexValueType Index2Offset(const Index & index, const Index & offsetTable) { long v = index[0]; for(int l=1; l BSplineWeightsCalculator:: BSplineWeightsCalculator() { mWeightsAreUpToDate = false; } //==================================================================== //==================================================================== template void BSplineWeightsCalculator:: SetSplineOrder(int splineOrder) { SizeType temp; for(int l=0; l void BSplineWeightsCalculator:: SetSplineOrders(const SizeType & splineOrder) { // Compute support size mSupportSize = 1; for(int l=0; l void BSplineWeightsCalculator:: SetSamplingFactor(int sampling) { for(int l=0; l void BSplineWeightsCalculator:: SetSamplingFactors(const SizeType & sampling) { for(int l=0; l typename BSplineWeightsCalculator::InitialWeightsType & BSplineWeightsCalculator:: GetInitialWeights(int order) { if (!mBasisFunctionCoefficientsMatrixAreUpToDate[order]) ComputeBasisFunctionCoefficientsMatrix(order); return mBasisFunctionCoefficientsMatrix[order]; } //==================================================================== //==================================================================== template inline T factorial(T rhs) { T lhs = (T)1; for(T x=(T)1; x<=rhs; ++x) { lhs *= x; } return lhs; } //==================================================================== //==================================================================== template double BSplineWeightsCalculator:: BinomialCoefficient(int i, int j) { double f = (factorial(i))/(factorial(j) * factorial(i-j)); return f; } //==================================================================== //==================================================================== template void BSplineWeightsCalculator:: 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; mBasisFunctionCoefficientsMatrix[order] = InitialWeightsType(); mBasisFunctionCoefficientsMatrix[order].resize(s); for(int i=0; i TCoefficientType BSplineWeightsCalculator:: 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) { int s = order+1; w.resize(s); for(int k=0; k