File: itkPatchBasedDenoisingImageFilterTest.cxx

package info (click to toggle)
insighttoolkit5 5.4.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 704,384 kB
  • sloc: cpp: 783,592; ansic: 628,724; xml: 44,704; fortran: 34,250; python: 22,874; sh: 4,078; pascal: 2,636; lisp: 2,158; makefile: 464; yacc: 328; asm: 205; perl: 203; lex: 146; tcl: 132; javascript: 98; csh: 81
file content (610 lines) | stat: -rw-r--r-- 25,692 bytes parent folder | download
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
/*=========================================================================
 *
 *  Copyright NumFOCUS
 *
 *  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
 *
 *         https://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.
 *
 *=========================================================================*/

#include "itkImage.h"
#include "itkVectorImage.h"
#include "itkMath.h"
#include "itkMinimumMaximumImageCalculator.h"
#include "itkRGBPixel.h"
#include "itkRGBAPixel.h"
#include "itkDiffusionTensor3D.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
#include "itkMeasurementVectorTraits.h"
#include "itkStdStreamLogOutput.h"
#include "itkGaussianRandomSpatialNeighborSubsampler.h"
#include "itkPatchBasedDenoisingImageFilter.h"
#include "itkTestingMacros.h"


template <typename TFilter>
typename TFilter::RealArrayType
ParseKernelBandwithSigma(char * kernelBandwithSigmaIn, unsigned int numIndependentComponents)
{
  typename TFilter::RealArrayType kernelBandwithSigmaOut;
  kernelBandwithSigmaOut.SetSize(numIndependentComponents);

  // Get the individual components
  char *                                     endPtr;
  unsigned int                               i = 0;
  typename TFilter::RealArrayType::ValueType value;
  while (*kernelBandwithSigmaIn && i < numIndependentComponents)
  {
    value = strtod(kernelBandwithSigmaIn, &endPtr);
    if (kernelBandwithSigmaIn == endPtr)
    {
      (*kernelBandwithSigmaIn)++;
    }
    else if (endPtr == nullptr || *endPtr == 0)
    {
      kernelBandwithSigmaOut[i] = value;
      break;
    }
    else
    {
      kernelBandwithSigmaOut[i] = value;
      kernelBandwithSigmaIn = endPtr + 1;
    }
    ++i;
  }

  return kernelBandwithSigmaOut;
}

template <typename ImageT>
int
doDenoising(const std::string & inputFileName,
            const std::string & outputFileName,
            const unsigned int  numIterations,
            const int           numThreads,
            char *              kernelBandwithSigma,
            bool                alwaysTreatComponentsAsEuclidean,
            bool                manualReinitialization,
            const int           numToSample,
            bool                computeConditionalDerivatives,
            const double        kernelBandwidthMultiplicationFactor,
            const std::string & noiseModelStr,
            const double        noiseModelFidelityWeight)
{
  using ReaderType = itk::ImageFileReader<ImageT>;

  using FilterType = itk::PatchBasedDenoisingImageFilter<ImageT, ImageT>;

  using SamplerType = itk::Statistics::GaussianRandomSpatialNeighborSubsampler<typename FilterType::PatchSampleType,
                                                                               typename ImageT::RegionType>;

  using OutputImageType = typename FilterType::OutputImageType;

  using WriterType = itk::ImageFileWriter<OutputImageType>;

  // Read the noisy image to be denoised
  auto reader = ReaderType::New();
  reader->SetFileName(inputFileName);

  ITK_TRY_EXPECT_NO_EXCEPTION(reader->Update());


  // Create filter and initialize
  auto filter = FilterType::New();

  typename FilterType::InputImageType::Pointer inputImage = reader->GetOutput();
  filter->SetInput(inputImage);

  // Set whether conditional derivatives should be used estimating sigma
  ITK_TEST_SET_GET_BOOLEAN(filter, ComputeConditionalDerivatives, computeConditionalDerivatives);

  // Patch radius is same for all dimensions of the image
  constexpr unsigned int patchRadius = 4;
  filter->SetPatchRadius(patchRadius);
  ITK_TEST_SET_GET_VALUE(patchRadius, filter->GetPatchRadius());

  // Instead of directly setting the weights, could also specify type
  bool useSmoothDiscPatchWeights = true;
  ITK_TEST_SET_GET_BOOLEAN(filter, UseSmoothDiscPatchWeights, useSmoothDiscPatchWeights);
  bool useFastTensorComputations = true;
  ITK_TEST_SET_GET_BOOLEAN(filter, UseFastTensorComputations, useFastTensorComputations);

  // Noise model to use
  typename FilterType::NoiseModelEnum noiseModel;
  if (noiseModelStr == "GAUSSIAN")
  {
    noiseModel = FilterType::NoiseModelEnum::GAUSSIAN;
  }
  else if (noiseModelStr == "RICIAN")
  {
    noiseModel = FilterType::NoiseModelEnum::RICIAN;
  }
  else if (noiseModelStr == "POISSON")
  {
    noiseModel = FilterType::NoiseModelEnum::POISSON;
  }
  else
  {
    noiseModel = FilterType::NoiseModelEnum::NOMODEL;
  }
  filter->SetNoiseModel(noiseModel);
  ITK_TEST_SET_GET_VALUE(noiseModel, filter->GetNoiseModel());

  // Stepsize or weight for smoothing term
  double smoothingWeight = 1.0;
  filter->SetSmoothingWeight(smoothingWeight);
  ITK_TEST_SET_GET_VALUE(smoothingWeight, filter->GetSmoothingWeight());

  // Stepsize or weight for fidelity term
  filter->SetNoiseModelFidelityWeight(noiseModelFidelityWeight);
  ITK_TEST_SET_GET_VALUE(noiseModelFidelityWeight, filter->GetNoiseModelFidelityWeight());

  // Number of iterations over the image of denoising
  filter->SetNumberOfIterations(numIterations);
  ITK_TEST_SET_GET_VALUE(numIterations, filter->GetNumberOfIterations());

  ITK_TEST_SET_GET_BOOLEAN(filter, AlwaysTreatComponentsAsEuclidean, alwaysTreatComponentsAsEuclidean);

  ITK_TEST_SET_GET_BOOLEAN(filter, ManualReinitialization, manualReinitialization);

  // Number of threads to use in parallel
  filter->SetNumberOfWorkUnits(numThreads);

  // Sampling the image to find similar patches
  auto sampler = SamplerType::New();

  // Variance (in physical units) for semi-local Gaussian sampling
  sampler->SetVariance(400);

  // Rectangular window restricting the Gaussian sampling
  sampler->SetRadius(50); // 2.5 * standard deviation

  // Number of random sample "patches" to use for computations
  sampler->SetNumberOfResultsRequested(numToSample);

  // Sampler can be complete neighborhood sampler, random neighborhood sampler,
  // Gaussian sampler, etc.
  filter->SetSampler(sampler);
  ITK_TEST_SET_GET_VALUE(sampler, filter->GetSampler());

  // Automatic estimation of the kernel bandwidth
  bool kernelBandwidthEstimation = true;
  ITK_TEST_SET_GET_BOOLEAN(filter, KernelBandwidthEstimation, kernelBandwidthEstimation);

  // Update bandwidth every 'n' iterations
  unsigned int kernelBandwidthUpdateFrequency = 3;
  filter->SetKernelBandwidthUpdateFrequency(kernelBandwidthUpdateFrequency);
  ITK_TEST_SET_GET_VALUE(kernelBandwidthUpdateFrequency, filter->GetKernelBandwidthUpdateFrequency());

  // Use 20% of the pixels for the sigma update calculation
  double kernelBandwidthFractionPixelsForEstimation = 0.20;
  filter->SetKernelBandwidthFractionPixelsForEstimation(kernelBandwidthFractionPixelsForEstimation);
  ITK_TEST_SET_GET_VALUE(kernelBandwidthFractionPixelsForEstimation,
                         filter->GetKernelBandwidthFractionPixelsForEstimation());

  // Multiplication factor modifying the automatically-estimated kernel sigma
  filter->SetKernelBandwidthMultiplicationFactor(kernelBandwidthMultiplicationFactor);
  ITK_TEST_SET_GET_VALUE(kernelBandwidthMultiplicationFactor, filter->GetKernelBandwidthMultiplicationFactor());

  // Test the filter exceptions
  //

  // Test the nonpositive pixel component exception for the RICIAN and POISSON
  // noise models.
  // Temporarily modify the value of an arbitrary pixel of the input image to
  // get a nonpositive value.
  if (filter->GetNoiseModel() == FilterType::NoiseModelEnum::RICIAN ||
      filter->GetNoiseModel() == FilterType::NoiseModelEnum::POISSON)
  {
    typename ImageT::IndexType::IndexValueType indexValue = 0;
    typename ImageT::IndexType                 pixelIndex;
    pixelIndex.Fill(indexValue);

    typename ImageT::PixelType originalPixelValue = inputImage->GetPixel(pixelIndex);

    typename ImageT::PixelType nonpositivePixelValue = itk::NumericTraits<typename ImageT::PixelType>::NonpositiveMin();
    inputImage->SetPixel(pixelIndex, nonpositivePixelValue);


    ITK_TRY_EXPECT_EXCEPTION(filter->Update());

    std::cout << "NumIndependentComponents: " << filter->GetNumIndependentComponents() << std::endl;

    // Restore the original pixel value
    inputImage->SetPixel(pixelIndex, originalPixelValue);
  }


  // Denoise the image
  ITK_TRY_EXPECT_NO_EXCEPTION(filter->Update());


  // Exercise the PrintSelf method to know the patch radius in voxels once
  // the filter has been updated
  std::cout << filter << std::endl;

  // Regression test
  typename FilterType::RealArrayType expectedKernelBandwidthSigma =
    ParseKernelBandwithSigma<FilterType>(kernelBandwithSigma, filter->GetNumIndependentComponents());
  typename FilterType::RealArrayType resultKernelBandwidthSigma = filter->GetKernelBandwidthSigma();
  if (expectedKernelBandwidthSigma.Size() != resultKernelBandwidthSigma.Size())
  {
    std::cout << "Error in GetKernelBandwidthSigma() " << std::endl;
    std::cout << "Expected value: " << expectedKernelBandwidthSigma << ", but got: " << resultKernelBandwidthSigma
              << std::endl;
    std::cout << "Array size mismatch." << std::endl;
    std::cout << "Test failed!" << std::endl;
    return EXIT_FAILURE;
  }
  else
  {
    typename FilterType::RealArrayType::iterator expectedKernelBandwidthSigmaIt = expectedKernelBandwidthSigma.begin();
    typename FilterType::RealArrayType::iterator resultKernelBandwidthSigmaIt = resultKernelBandwidthSigma.begin();

    unsigned int i = 0;

    // Although some cases converge to a higher degree of accuracy, the
    // tolerance set for the test is relatively loose due to the convergence
    // value of the algorithm set by
    // itk::PatchBasedDenoisingImageFilter::m_SigmaUpdateConvergenceTolerance
    // Hence, some tests require such a low degree of accuracy.
    //
    while (expectedKernelBandwidthSigmaIt != expectedKernelBandwidthSigma.end() &&
           resultKernelBandwidthSigmaIt != resultKernelBandwidthSigma.end())
    {
      typename FilterType::RealArrayType::ValueType expectedValue = *expectedKernelBandwidthSigmaIt;
      typename FilterType::RealArrayType::ValueType resultValue = *resultKernelBandwidthSigmaIt;
      double                                        tolerance = 1e-2 * expectedValue;
      if (!itk::Math::FloatAlmostEqual(expectedValue, resultValue, 10, tolerance))
      {
        std::cout.precision(static_cast<unsigned int>(itk::Math::abs(std::log10(tolerance))));
        std::cout << "Error in GetKernelBandwidthSigma() "
                  << "at index: [" << i << ']' << std::endl;
        std::cout << "Expected value: " << expectedValue << ", but got: " << resultValue << std::endl;
        std::cout << "Test failed!" << std::endl;
        return EXIT_FAILURE;
      }
      ++expectedKernelBandwidthSigmaIt;
      ++resultKernelBandwidthSigmaIt;
      ++i;
    }
  }

  // Write the denoised image to file
  auto writer = WriterType::New();
  writer->SetFileName(outputFileName);
  writer->SetInput(filter->GetOutput());

  ITK_TRY_EXPECT_NO_EXCEPTION(writer->Update());


  std::cout << "Test finished" << std::endl;
  return EXIT_SUCCESS;
}

int
itkPatchBasedDenoisingImageFilterTest(int argc, char * argv[])
{
  if (argc < 8)
  {
    std::cerr << "Missing command line arguments" << std::endl;
    std::cerr << "Usage: " << itkNameOfTestExecutableMacro(argv) << " inputImageFileName outputImageFileName"
              << " numDimensions numComponents"
              << " kernelBandwithSigma"
              << " alwaysTreatComponentsAsEuclidean"
              << " manualReinitialization"
              << " [numIterations] [numThreads]"
              << " [numPatchesToSample]"
              << " [computeConditionalDerivatives]"
              << " [kernelBandwidthMultiplicationFactor]"
              << " [noiseModel] [noiseModelFidelityWeight]" << std::endl;
    return EXIT_FAILURE;
  }

  // Exercise basic object methods
  // Done outside the helper function in the test because GCC is limited
  // when calling overloaded base class functions.
  using PixelType = float;
  using ImageType = itk::Image<PixelType, 3>;
  using FilterType = itk::PatchBasedDenoisingImageFilter<ImageType, ImageType>;

  auto filter = FilterType::New();

  ITK_EXERCISE_BASIC_OBJECT_METHODS(filter, PatchBasedDenoisingImageFilter, PatchBasedDenoisingBaseImageFilter);

  const std::string inFileName(argv[1]);

  const std::string outFileName(argv[2]);

  const unsigned int numDimensions = std::stoi(argv[3]);

  const unsigned int numComponents = std::stoi(argv[4]);

  char * kernelBandwithSigma = argv[5];

  const bool alwaysTreatComponentsAsEuclidean = std::stoi(argv[6]);
  const bool manualReinitialization = std::stoi(argv[7]);

  unsigned int numIterations = 1;
  if (argc > 8)
  {
    numIterations = std::stoi(argv[8]);
  }

  unsigned int numThreads = 1;
  if (argc > 9)
  {
    numThreads = std::stoi(argv[9]);
  }

  unsigned int numToSample = 1000;
  if (argc > 10)
  {
    numToSample = std::stoi(argv[10]);
  }

  bool computeConditionalDerivatives = false;
  if (argc > 11)
  {
    computeConditionalDerivatives = static_cast<bool>(std::stoi(argv[11]));
  }

  double kernelBandwidthMultFactor = 1.0;
  if (argc > 12)
  {
    kernelBandwidthMultFactor = std::stod(argv[12]);
  }

  const std::vector<std::string> modelChoices{ "GAUSSIAN", "RICIAN", "POISSON", "NOMODEL" };
  std::string                    noiseModel = modelChoices[0];

  double noiseModelFidelityWeight = 0.0;
  if (argc > 13)
  {
    noiseModel = argv[13];
    bool validChoice = false;
    for (const auto & modelChoice : modelChoices)
    {
      if (noiseModel == modelChoice)
      {
        validChoice = true;
      }
    }
    if (!validChoice)
    {
      std::cerr << "Test failed!" << std::endl;
      std::cerr << noiseModel << " is not a valid noise model choice. Please choose one of: ";
      for (const auto & modelChoice : modelChoices)
      {
        std::cerr << modelChoice << ' ' << std::endl;
      }
      return EXIT_FAILURE;
    }
    if (argc > 14)
    {
      noiseModelFidelityWeight = std::stod(argv[14]);
    }
    else
    {
      std::cerr << "Test failed!" << std::endl;
      std::cerr << "Must also specify a noise model fidelity weight when a noise model is specified." << std::endl;
      return EXIT_FAILURE;
    }
  }

  using PixelComponentType = float;

  using OneComponentType = PixelComponentType;
  using ThreeComponentType = itk::RGBPixel<PixelComponentType>;
  using FourComponentType = itk::RGBAPixel<PixelComponentType>;
  using SixComponentType = itk::DiffusionTensor3D<PixelComponentType>;

  using OneComponent2DImage = itk::Image<OneComponentType, 2>;
  using OneComponent3DImage = itk::Image<OneComponentType, 3>;

  // using TwoComponent2DImage = itk::VectorImage< PixelComponentType, 2 >;
  // using TwoComponent3DImage = itk::VectorImage< PixelComponentType, 3 >;

  using ThreeComponent2DImage = itk::Image<ThreeComponentType, 2>;
  using ThreeComponent3DImage = itk::Image<ThreeComponentType, 3>;

  using FourComponent2DImage = itk::Image<FourComponentType, 2>;
  using FourComponent3DImage = itk::Image<FourComponentType, 3>;

  using SixComponent2DImage = itk::Image<SixComponentType, 2>;
  using SixComponent3DImage = itk::Image<SixComponentType, 3>;

  // Test streaming enumeration for PatchBasedDenoisingBaseImageFilterEnums::NoiseModel elements
  const std::set<itk::PatchBasedDenoisingBaseImageFilterEnums::NoiseModel> allNoiseModel{
    itk::PatchBasedDenoisingBaseImageFilterEnums::NoiseModel::NOMODEL,
    itk::PatchBasedDenoisingBaseImageFilterEnums::NoiseModel::GAUSSIAN,
    itk::PatchBasedDenoisingBaseImageFilterEnums::NoiseModel::RICIAN,
    itk::PatchBasedDenoisingBaseImageFilterEnums::NoiseModel::POISSON
  };
  for (const auto & ee : allNoiseModel)
  {
    std::cout << "STREAMED ENUM VALUE PatchBasedDenoisingBaseImageFilterEnums::NoiseModel: " << ee << std::endl;
  }

  // Test streaming enumeration for PatchBasedDenoisingBaseImageFilterEnums::ComponentSpace elements
  const std::set<itk::PatchBasedDenoisingBaseImageFilterEnums::ComponentSpace> allComponentSpace{
    itk::PatchBasedDenoisingBaseImageFilterEnums::ComponentSpace::EUCLIDEAN,
    itk::PatchBasedDenoisingBaseImageFilterEnums::ComponentSpace::RIEMANNIAN
  };
  for (const auto & ee : allComponentSpace)
  {
    std::cout << "STREAMED ENUM VALUE PatchBasedDenoisingBaseImageFilterEnums::ComponentSpace: " << ee << std::endl;
  }

  // Test streaming enumeration for PatchBasedDenoisingBaseImageFilterEnums::FilterState elements
  const std::set<itk::PatchBasedDenoisingBaseImageFilterEnums::FilterState> allFilterState{
    itk::PatchBasedDenoisingBaseImageFilterEnums::FilterState::UNINITIALIZED,
    itk::PatchBasedDenoisingBaseImageFilterEnums::FilterState::INITIALIZED
  };
  for (const auto & ee : allFilterState)
  {
    std::cout << "STREAMED ENUM VALUE PatchBasedDenoisingBaseImageFilterEnums::FilterStateEnum: " << ee << std::endl;
  }

  if (numComponents == 1 && numDimensions == 2)
  {
    return doDenoising<OneComponent2DImage>(inFileName,
                                            outFileName,
                                            numIterations,
                                            numThreads,
                                            kernelBandwithSigma,
                                            alwaysTreatComponentsAsEuclidean,
                                            manualReinitialization,
                                            numToSample,
                                            computeConditionalDerivatives,
                                            kernelBandwidthMultFactor,
                                            noiseModel,
                                            noiseModelFidelityWeight);
  }
  /*else if( numComponents == 2 && numDimensions == 2 )
    {
     return doDenoising< TwoComponent2DImage >( inFileName, outFileName,
                                              numIterations, numThreads,
                                              kernelBandwithSigma,
                                              alwaysTreatComponentsAsEuclidean,
                                              manualReinitialization,
                                              numToSample,
                                              computeConditionalDerivatives,
                                              kernelBandwidthMultFactor,
                                              noiseModel, noiseModelFidelityWeight );
    }*/
  else if (numComponents == 3 && numDimensions == 2)
  {
    return doDenoising<ThreeComponent2DImage>(inFileName,
                                              outFileName,
                                              numIterations,
                                              numThreads,
                                              kernelBandwithSigma,
                                              alwaysTreatComponentsAsEuclidean,
                                              manualReinitialization,
                                              numToSample,
                                              computeConditionalDerivatives,
                                              kernelBandwidthMultFactor,
                                              noiseModel,
                                              noiseModelFidelityWeight);
  }
  else if (numComponents == 4 && numDimensions == 2)
  {
    return doDenoising<FourComponent2DImage>(inFileName,
                                             outFileName,
                                             numIterations,
                                             numThreads,
                                             kernelBandwithSigma,
                                             alwaysTreatComponentsAsEuclidean,
                                             manualReinitialization,
                                             numToSample,
                                             computeConditionalDerivatives,
                                             kernelBandwidthMultFactor,
                                             noiseModel,
                                             noiseModelFidelityWeight);
  }
  else if (numComponents == 6 && numDimensions == 2)
  {
    return doDenoising<SixComponent2DImage>(inFileName,
                                            outFileName,
                                            numIterations,
                                            numThreads,
                                            kernelBandwithSigma,
                                            alwaysTreatComponentsAsEuclidean,
                                            manualReinitialization,
                                            numToSample,
                                            computeConditionalDerivatives,
                                            kernelBandwidthMultFactor,
                                            noiseModel,
                                            noiseModelFidelityWeight);
  }
  else if (numComponents == 1 && numDimensions == 3)
  {
    return doDenoising<OneComponent3DImage>(inFileName,
                                            outFileName,
                                            numIterations,
                                            numThreads,
                                            kernelBandwithSigma,
                                            alwaysTreatComponentsAsEuclidean,
                                            manualReinitialization,
                                            numToSample,
                                            computeConditionalDerivatives,
                                            kernelBandwidthMultFactor,
                                            noiseModel,
                                            noiseModelFidelityWeight);
  }
  /*else if( numComponents == 2 && numDimensions == 3 )
    {
    return doDenoising< TwoComponent3DImage >( inFileName, outFileName,
                                             numIterations, numThreads,
                                             kernelBandwithSigma,
                                             alwaysTreatComponentsAsEuclidean,
                                             manualReinitialization,
                                             numToSample,
                                             computeConditionalDerivatives,
                                             kernelBandwidthMultFactor,
                                             noiseModel, noiseModelFidelityWeight );
    }*/
  else if (numComponents == 3 && numDimensions == 3)
  {
    return doDenoising<ThreeComponent3DImage>(inFileName,
                                              outFileName,
                                              numIterations,
                                              numThreads,
                                              kernelBandwithSigma,
                                              alwaysTreatComponentsAsEuclidean,
                                              manualReinitialization,
                                              numToSample,
                                              computeConditionalDerivatives,
                                              kernelBandwidthMultFactor,
                                              noiseModel,
                                              noiseModelFidelityWeight);
  }
  else if (numComponents == 4 && numDimensions == 3)
  {
    return doDenoising<FourComponent3DImage>(inFileName,
                                             outFileName,
                                             numIterations,
                                             numThreads,
                                             kernelBandwithSigma,
                                             alwaysTreatComponentsAsEuclidean,
                                             manualReinitialization,
                                             numToSample,
                                             computeConditionalDerivatives,
                                             kernelBandwidthMultFactor,
                                             noiseModel,
                                             noiseModelFidelityWeight);
  }
  else if (numComponents == 6 && numDimensions == 3)
  {
    return doDenoising<SixComponent3DImage>(inFileName,
                                            outFileName,
                                            numIterations,
                                            numThreads,
                                            kernelBandwithSigma,
                                            alwaysTreatComponentsAsEuclidean,
                                            manualReinitialization,
                                            numToSample,
                                            computeConditionalDerivatives,
                                            kernelBandwidthMultFactor,
                                            noiseModel,
                                            noiseModelFidelityWeight);
  }
  else
  {
    std::cout << "Test failed!" << std::endl;
    std::cout << "Combination of " << numComponents << " components and " << numDimensions << " dimensions "
              << "isn't supported in this test driver." << std::endl;
    return EXIT_FAILURE;
  }
}