/usr/include/ITK-4.5/itkBSplineTransform.hxx is in libinsighttoolkit4-dev 4.5.0-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 | /*=========================================================================
*
* Copyright Insight Software Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0.txt
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*=========================================================================*/
#ifndef __itkBSplineTransform_hxx
#define __itkBSplineTransform_hxx
#include "itkBSplineTransform.h"
#include "itkContinuousIndex.h"
#include "itkImageScanlineConstIterator.h"
#include "itkImageRegionConstIteratorWithIndex.h"
namespace itk
{
// Constructor with default arguments
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::BSplineTransform() : Superclass( )
{
/** Fixed Parameters store the following information:
* grid size
* grid origin
* grid spacing
* grid direction
* The size of these is equal to the NInputDimensions
*/
// For example 3D image has FixedParameters of:
// [size[0],size[1],size[2],
// origin[0],origin[1],origin[2],
// spacing[0],spacing[1],spacing[2],
// dir[0][0],dir[1][0],dir[2][0],
// dir[0][1],dir[1][1],dir[2][1],
// dir[0][2],dir[1][2],dir[2][2]]
this->m_TransformDomainMeshSize.Fill( 0 );
this->m_TransformDomainOrigin.Fill( 0.0 );
this->m_TransformDomainPhysicalDimensions.Fill( 1.0 );
this->m_TransformDomainDirection.SetIdentity();
this->m_TransformDomainDirectionInverse.SetIdentity();
SizeType meshSize;
meshSize.Fill( 1 );
this->SetTransformDomainMeshSize( meshSize );
this->SetFixedParametersFromTransformDomainInformation();
this->SetCoefficientImageInformationFromFixedParameters();
}
// Destructor
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::~BSplineTransform()
{
}
// Get the number of parameters
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
typename BSplineTransform<TScalar, NDimensions, VSplineOrder>::NumberOfParametersType
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::GetNumberOfParameters() const
{
// The number of parameters equal SpaceDimension * number of
// of pixels in the grid region.
return SpaceDimension * this->GetNumberOfParametersPerDimension();
}
// Get the number of parameters per dimension
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
typename BSplineTransform<TScalar, NDimensions, VSplineOrder>::NumberOfParametersType
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::GetNumberOfParametersPerDimension() const
{
// The number of parameters per dimension equal number of
// of pixels in the grid region.
NumberOfParametersType numberOfParametersPerDimension = 1;
for( unsigned int i = 0; i < SpaceDimension; i++ )
{
numberOfParametersPerDimension *= static_cast<NumberOfParametersType>( this->m_FixedParameters[i] );
}
return numberOfParametersPerDimension;
}
// Set the transform origin
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::SetTransformDomainOrigin( const OriginType & origin )
{
if( this->m_TransformDomainOrigin != origin )
{
this->m_TransformDomainOrigin = origin;
this->SetFixedParametersFromTransformDomainInformation();
this->SetCoefficientImageInformationFromFixedParameters();
this->Modified();
}
}
// Set the transform dimensions
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::SetTransformDomainPhysicalDimensions( const PhysicalDimensionsType & dims )
{
if( this->m_TransformDomainPhysicalDimensions != dims )
{
this->m_TransformDomainPhysicalDimensions = dims;
this->SetFixedParametersFromTransformDomainInformation();
this->SetCoefficientImageInformationFromFixedParameters();
this->Modified();
}
}
// Set the transform
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::SetTransformDomainDirection( const DirectionType & direction )
{
if( this->m_TransformDomainDirection != direction )
{
this->m_TransformDomainDirection = direction;
this->m_TransformDomainDirectionInverse = direction.GetInverse();
this->SetFixedParametersFromTransformDomainInformation();
this->SetCoefficientImageInformationFromFixedParameters();
this->Modified();
}
}
// Set the transform domain mesh size
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::SetTransformDomainMeshSize( const MeshSizeType & meshSize )
{
if( this->m_TransformDomainMeshSize != meshSize )
{
this->m_TransformDomainMeshSize = meshSize;
this->SetFixedParametersFromTransformDomainInformation();
this->SetCoefficientImageInformationFromFixedParameters();
// Check if we need to resize the default parameter buffer.
if( this->m_InternalParametersBuffer.GetSize() != this->GetNumberOfParameters() )
{
this->m_InternalParametersBuffer.SetSize( this->GetNumberOfParameters() );
// Fill with zeros for identity.
this->m_InternalParametersBuffer.Fill( 0 );
}
this->Modified();
}
}
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::SetCoefficientImageInformationFromFixedParameters()
{
// Fixed Parameters store the following information:
// grid size
// grid origin
// grid spacing
// grid direction
// The size of these is equal to the NInputDimensions
// set the grid size parameters
SizeType gridSize;
for( unsigned int i = 0; i < NDimensions; i++ )
{
gridSize[i] = static_cast<SizeValueType>( this->m_FixedParameters[i] );
}
this->m_CoefficientImages[0]->SetRegions( gridSize );
// // Set the origin parameters
OriginType origin;
for( unsigned int i = 0; i < NDimensions; i++ )
{
origin[i] = this->m_FixedParameters[NDimensions + i];
}
this->m_CoefficientImages[0]->SetOrigin( origin );
// // Set the spacing parameters
SpacingType spacing;
for( unsigned int i = 0; i < NDimensions; i++ )
{
spacing[i] = this->m_FixedParameters[2 * NDimensions + i];
}
this->m_CoefficientImages[0]->SetSpacing( spacing );
// // Set the direction parameters
DirectionType direction;
for( unsigned int di = 0; di < NDimensions; di++ )
{
for( unsigned int dj = 0; dj < NDimensions; dj++ )
{
direction[di][dj] =
this->m_FixedParameters[3 * NDimensions + ( di * NDimensions + dj )];
}
}
this->m_CoefficientImages[0]->SetDirection( direction );
this->m_CoefficientImages[0]->Allocate();
this->m_CoefficientImages[0]->FillBuffer( 0 );
// Copy the information to the rest of the images
for( unsigned int i = 1; i < SpaceDimension; i++ )
{
this->m_CoefficientImages[i]->CopyInformation( this->m_CoefficientImages[0] );
this->m_CoefficientImages[i]->SetRegions(
this->m_CoefficientImages[0]->GetLargestPossibleRegion() );
this->m_CoefficientImages[i]->Allocate();
this->m_CoefficientImages[i]->FillBuffer( 0 );
}
}
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::SetFixedParametersGridSizeFromTransformDomainInformation() const
{
// Set the grid size parameters
for( unsigned int i = 0; i < NDimensions; i++ )
{
this->m_FixedParameters[i] = static_cast<ParametersValueType>(
this->m_TransformDomainMeshSize[i] + SplineOrder );
}
}
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::SetFixedParametersGridOriginFromTransformDomainInformation() const
{
// Set the origin parameters
typedef typename ImageType::PointType PointType;
PointType origin;
origin.Fill( 0.0 );
for( unsigned int i = 0; i < NDimensions; i++ )
{
ScalarType gridSpacing = this->m_TransformDomainPhysicalDimensions[i] /
static_cast<ScalarType>( this->m_TransformDomainMeshSize[i] );
origin[i] = -0.5 * gridSpacing * ( SplineOrder - 1 );
}
origin = this->m_TransformDomainDirection * origin;
for( unsigned int i = 0; i < NDimensions; i++ )
{
this->m_FixedParameters[NDimensions + i] = static_cast<ParametersValueType>(
origin[i] + this->m_TransformDomainOrigin[i] );
}
}
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::SetFixedParametersGridSpacingFromTransformDomainInformation() const
{
// Set the spacing parameters
for( unsigned int i = 0; i < NDimensions; i++ )
{
ScalarType gridSpacing = this->m_TransformDomainPhysicalDimensions[i]
/ static_cast<ScalarType>( this->m_TransformDomainMeshSize[i] );
this->m_FixedParameters[2 * NDimensions + i] =
static_cast<ParametersValueType>( gridSpacing );
}
}
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::SetFixedParametersGridDirectionFromTransformDomainInformation() const
{
// Set the direction parameters
for( unsigned int di = 0; di < NDimensions; di++ )
{
for( unsigned int dj = 0; dj < NDimensions; dj++ )
{
this->m_FixedParameters[3 * NDimensions + ( di * NDimensions + dj )] =
static_cast<ParametersValueType>( this->m_TransformDomainDirection[di][dj] );
}
}
}
// Set the Fixed Parameters
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::SetFixedParameters( const ParametersType & passedParameters )
{
// check if the number of passedParameters match the
// expected number of this->m_FixedParameters
if( passedParameters.Size() == this->m_FixedParameters.Size() )
{
for( unsigned int i = 0; i < NDimensions * ( 3 + NDimensions ); ++i )
{
this->m_FixedParameters[i] = passedParameters[i];
}
this->Modified();
}
else
{
itkExceptionMacro( << "Mismatched between parameters size "
<< passedParameters.size()
<< " and the required number of fixed parameters "
<< this->m_FixedParameters.Size() );
}
SizeType gridSize;
for( unsigned int i = 0; i < NDimensions; i++ )
{
gridSize[i] = static_cast<SizeValueType>( this->m_FixedParameters[i] );
}
this->m_CoefficientImages[0]->SetRegions( gridSize );
// // Set the origin parameters
OriginType origin;
for( unsigned int i = 0; i < NDimensions; i++ )
{
origin[i] = this->m_FixedParameters[NDimensions + i];
}
this->m_CoefficientImages[0]->SetOrigin( origin );
// // Set the spacing parameters
SpacingType spacing;
for( unsigned int i = 0; i < NDimensions; i++ )
{
spacing[i] = this->m_FixedParameters[2 * NDimensions + i];
}
this->m_CoefficientImages[0]->SetSpacing( spacing );
// // Set the direction parameters
DirectionType direction;
for( unsigned int di = 0; di < NDimensions; di++ )
{
for( unsigned int dj = 0; dj < NDimensions; dj++ )
{
direction[di][dj] =
this->m_FixedParameters[3 * NDimensions + ( di * NDimensions + dj )];
}
}
this->m_CoefficientImages[0]->SetDirection( direction );
// Copy the information to the rest of the images
for( unsigned int i = 1; i < SpaceDimension; i++ )
{
this->m_CoefficientImages[i]->CopyInformation( this->m_CoefficientImages[0] );
this->m_CoefficientImages[i]->SetRegions(
this->m_CoefficientImages[0]->GetLargestPossibleRegion() );
}
}
// Set the B-Spline coefficients using input images
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::SetCoefficientImages( const CoefficientImageArray & images )
{
bool validArrayOfImages = true;
for( unsigned int j = 0; j < SpaceDimension; j++ )
{
validArrayOfImages &= ( images[0].IsNotNull() );
}
if( validArrayOfImages )
{
typedef typename ImageType::PointType PointType;
PointType origin;
origin.Fill( 0.0 );
for( unsigned int i = 0; i < SpaceDimension; i++ )
{
this->m_TransformDomainMeshSize[i] =
images[0]->GetLargestPossibleRegion().GetSize()[i] - SplineOrder;
this->m_TransformDomainPhysicalDimensions[i] = static_cast<ScalarType>(
this->m_TransformDomainMeshSize[i] ) * images[0]->GetSpacing()[i];
origin[i] += ( images[0]->GetSpacing()[i] * 0.5 * ( SplineOrder - 1 ) );
}
origin = this->m_TransformDomainDirection * origin;
const SizeValueType numberOfPixels =
images[0]->GetLargestPossibleRegion().GetNumberOfPixels();
const SizeValueType totalParameters = numberOfPixels * SpaceDimension;
this->m_InternalParametersBuffer.SetSize( totalParameters );
for( unsigned int j = 0; j < SpaceDimension; j++ )
{
const SizeValueType numberOfPixels_j = images[j]->GetLargestPossibleRegion().GetNumberOfPixels();
this->m_TransformDomainOrigin[j] = images[0]->GetOrigin()[j] + origin[j];
if( numberOfPixels_j * SpaceDimension != totalParameters )
{
itkExceptionMacro( << "SetCoefficientImage() has array of images that are "
<< "not the correct size. "
<< numberOfPixels_j * SpaceDimension << " != " << totalParameters
<< " for image at index " << j << " \n" << images[j]
);
}
const ParametersValueType * const baseImagePointer = images[j]->GetBufferPointer();
ParametersValueType *dataPointer = this->m_InternalParametersBuffer.data_block();
std::copy(baseImagePointer,
baseImagePointer+numberOfPixels,
dataPointer + j * numberOfPixels);
this->m_CoefficientImages[j]->CopyInformation( images[j] );
this->m_CoefficientImages[j]->SetRegions( images[j]->GetLargestPossibleRegion() );
}
this->SetFixedParametersFromTransformDomainInformation();
this->SetParameters( this->m_InternalParametersBuffer );
}
else
{
itkExceptionMacro( << "SetCoefficientImage() requires that an array of "
<< "correctly sized images be supplied.");
}
}
// Print self
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::PrintSelf( std::ostream & os, Indent indent ) const
{
this->Superclass::PrintSelf(os, indent);
os << indent << "TransformDomainOrigin: "
<< this->m_TransformDomainOrigin << std::endl;
os << indent << "TransformDomainPhysicalDimensions: "
<< this->m_TransformDomainPhysicalDimensions << std::endl;
os << indent << "TransformDomainDirection: "
<< this->m_TransformDomainDirection << std::endl;
os << indent << "GridSize: "
<< this->m_CoefficientImages[0]->GetLargestPossibleRegion().GetSize()
<< std::endl;
os << indent << "GridOrigin: "
<< this->m_CoefficientImages[0]->GetOrigin() << std::endl;
os << indent << "GridSpacing: "
<< this->m_CoefficientImages[0]->GetSpacing() << std::endl;
os << indent << "GridDirection: "
<< this->m_CoefficientImages[0]->GetDirection() << std::endl;
}
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
bool
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::InsideValidRegion( ContinuousIndexType & index ) const
{
const SizeType gridSize =
this->m_CoefficientImages[0]->GetLargestPossibleRegion().GetSize();
const ScalarType minLimit = 0.5 * static_cast<ScalarType>( SplineOrder - 1 );
//Needed so that index can be changed.
bool inside = true;
for( unsigned int j = 0; j < SpaceDimension; j++ )
{
ScalarType maxLimit = static_cast<ScalarType>( gridSize[j] ) - 0.5
* static_cast<ScalarType>( SplineOrder - 1 ) - 1.0;
if( index[j] == maxLimit )
{
index[j] -= 1e-6;
}
else if( index[j] >= maxLimit )
{
inside = false;
break;
}
else if( index[j] < minLimit )
{
inside = false;
break;
}
}
return inside;
}
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::TransformPoint( const InputPointType & point, OutputPointType & outputPoint,
WeightsType & weights, ParameterIndexArrayType & indices, bool & inside ) const
{
inside = true;
if( this->m_CoefficientImages[0]->GetBufferPointer() )
{
ContinuousIndexType index;
this->m_CoefficientImages[0]->TransformPhysicalPointToContinuousIndex( point, index );
// NOTE: if the support region does not lie totally within the grid
// we assume zero displacement and return the input point
inside = this->InsideValidRegion( index );
if( !inside )
{
outputPoint = point;
return;
}
IndexType supportIndex;
// Compute interpolation weights
this->m_WeightsFunction->Evaluate( index, weights, supportIndex );
// For each dimension, correlate coefficient with weights
SizeType supportSize;
supportSize.Fill( SplineOrder + 1 );
RegionType supportRegion;
supportRegion.SetSize( supportSize );
supportRegion.SetIndex( supportIndex );
outputPoint.Fill( NumericTraits<ScalarType>::Zero );
typedef ImageScanlineConstIterator<ImageType> IteratorType;
IteratorType coeffIterator[SpaceDimension];
unsigned long counter = 0;
const ParametersValueType *basePointer =
this->m_CoefficientImages[0]->GetBufferPointer();
for( unsigned int j = 0; j < SpaceDimension; j++ )
{
coeffIterator[j] =
IteratorType( this->m_CoefficientImages[j], supportRegion );
}
while( !coeffIterator[0].IsAtEnd() )
{
while( !coeffIterator[0].IsAtEndOfLine() )
{
// multiply weigth with coefficient
for( unsigned int j = 0; j < SpaceDimension; j++ )
{
outputPoint[j] += static_cast<ScalarType>(
weights[counter] * coeffIterator[j].Get() );
}
// populate the indices array
indices[counter] = &( coeffIterator[0].Value() ) - basePointer;
// go to next coefficient in the support region
++counter;
for( unsigned int j = 0; j < SpaceDimension; j++ )
{
++( coeffIterator[j] );
}
} // end scanline
for( unsigned int j = 0; j < SpaceDimension; j++ )
{
coeffIterator[j].NextLine();
}
}
// return results
for( unsigned int j = 0; j < SpaceDimension; j++ )
{
outputPoint[j] += point[j];
}
}
else
{
itkWarningMacro( "B-spline coefficients have not been set" );
for( unsigned int j = 0; j < SpaceDimension; j++ )
{
outputPoint[j] = point[j];
}
}
}
// Compute the Jacobian in one position
template <typename TScalar, unsigned int NDimensions, unsigned int VSplineOrder>
void
BSplineTransform<TScalar, NDimensions, VSplineOrder>
::ComputeJacobianWithRespectToParameters( const InputPointType & point,
JacobianType & jacobian ) const
{
// Zero all components of jacobian
jacobian.SetSize( SpaceDimension, this->GetNumberOfParameters() );
jacobian.Fill( 0.0 );
RegionType supportRegion;
SizeType supportSize;
supportSize.Fill( SplineOrder + 1 );
supportRegion.SetSize( supportSize );
ContinuousIndexType index;
this->m_CoefficientImages[0]->
TransformPhysicalPointToContinuousIndex( point, index );
// NOTE: if the support region does not lie totally within the grid we assume
// zero displacement and do no computations beyond zeroing out the value
// return the input point
if( !this->InsideValidRegion( index ) )
{
return;
}
// Compute interpolation weights
WeightsType weights( this->m_WeightsFunction->GetNumberOfWeights() );
IndexType supportIndex;
this->m_WeightsFunction->Evaluate( index, weights, supportIndex );
supportRegion.SetIndex( supportIndex );
IndexType startIndex =
this->m_CoefficientImages[0]->GetLargestPossibleRegion().GetIndex();
SizeType cumulativeGridSizes;
cumulativeGridSizes[0] = ( this->m_TransformDomainMeshSize[0] + SplineOrder );
for( unsigned int d = 1; d < SpaceDimension; d++ )
{
cumulativeGridSizes[d] = cumulativeGridSizes[d-1] * ( this->m_TransformDomainMeshSize[d] + SplineOrder );
}
SizeValueType numberOfParametersPerDimension = this->GetNumberOfParametersPerDimension();
ImageRegionConstIteratorWithIndex<ImageType> It( this->m_CoefficientImages[0], supportRegion );
unsigned long counter = 0;
for( It.GoToBegin(); !It.IsAtEnd(); ++It )
{
typename ImageType::OffsetType currentIndex = It.GetIndex() - startIndex;
unsigned long number = currentIndex[0];
for( unsigned int d = 1; d < SpaceDimension; d++ )
{
number += ( currentIndex[d] * cumulativeGridSizes[d-1] );
}
for( unsigned int d = 0; d < SpaceDimension; d++ )
{
jacobian( d, number + d * numberOfParametersPerDimension ) = weights[counter];
}
counter++;
}
}
} // namespace
#endif
|