forked from midas-journal/midas-journal-692
-
Notifications
You must be signed in to change notification settings - Fork 0
/
itkFastBilateralImageFilterTest3D.cxx
66 lines (54 loc) · 1.58 KB
/
itkFastBilateralImageFilterTest3D.cxx
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
#if defined(_MSC_VER)
#pragma warning ( disable : 4786 )
#endif
#include "itkFastBilateralImageFilter.h"
#include "itkImageFileReader.h"
#include "itkImageFileWriter.h"
/**
* This test was originally taken from the tests for the itkBilateralImageFilter
* and modified for the itkFastBilateralImageFilter.
*/
int main(int ac, char* av[] )
{
if(ac < 3)
{
std::cerr << "Usage: " << av[0] << " InputImage OutputImage\n";
return -1;
}
typedef unsigned char PixelType;
const unsigned int dimension = 3;
typedef itk::Image<PixelType, dimension> myImage;
itk::ImageFileReader<myImage>::Pointer input
= itk::ImageFileReader<myImage>::New();
input->SetFileName(av[1]);
// Create a filter
typedef itk::FastBilateralImageFilter<myImage,myImage> FilterType;
FilterType::Pointer filter = FilterType::New();
filter->SetInput(input->GetOutput());
// these settings reduce the amount of noise by a factor of 10
// when the original signal to noise level is 5
filter->SetDomainSigma( 4.0 );
filter->SetRangeSigma( 50.0 );
try
{
input->Update();
filter->Update();
}
catch (itk::ExceptionObject& e)
{
std::cerr << "Exception detected: " << e.GetDescription();
return -1;
}
catch (...)
{
std::cerr << "Some other exception occurred" << std::endl;
return -2;
}
// Generate test image
itk::ImageFileWriter<myImage>::Pointer writer;
writer = itk::ImageFileWriter<myImage>::New();
writer->SetInput( filter->GetOutput() );
writer->SetFileName( av[2] );
writer->Update();
return EXIT_SUCCESS;
}