1
1
/* =========================================================================
2
2
*
3
- * Copyright Insight Software Consortium
3
+ * Copyright NumFOCUS
4
4
*
5
5
* Licensed under the Apache License, Version 2.0 (the "License");
6
6
* you may not use this file except in compliance with the License.
15
15
* limitations under the License.
16
16
*
17
17
*=========================================================================*/
18
+
18
19
#include " itkImage.h"
19
20
#include " itkImageFileReader.h"
20
21
#include " itkImageFileWriter.h"
21
22
#include " itkAdditiveGaussianNoiseImageFilter.h"
22
23
23
24
int main ( int argc, char * argv[] )
24
25
{
25
- // Check for proper arguments, if not, explain usage.
26
+ // Check for proper arguments; if not, explain usage.
26
27
if ( argc != 5 )
27
28
{
28
29
std::cerr << " Usage: " << std::endl;
@@ -31,19 +32,21 @@ int main( int argc, char* argv[] )
31
32
std::cerr << std::endl;
32
33
return EXIT_FAILURE;
33
34
}
34
- // Initialize and assign user provided variables
35
- const std::string * inputImage = argv[1 ];
36
- const std::string * outputImage = argv[2 ];
37
- // get floating point numbers for the Mean and Standard Deviation to perform the algorithm
35
+
36
+ // Initialize and assign user provided variables
37
+ const char * inputImage = argv[1 ];
38
+ const char * outputImage = argv[2 ];
39
+
40
+ // Get floating point numbers for the mean and std dev to perform the algorithm
38
41
const double mean = std::stod (argv[3 ]);
39
42
const double deviation = std::stod (argv[4 ]);
40
43
41
44
constexpr unsigned int Dimension = 2 ;
42
- // Use unsigned char so file will save to .png
45
+ // Use unsigned char to save to PNG format
43
46
using PixelType = unsigned char ;
44
47
using ImageType = itk::Image< PixelType, Dimension >;
45
48
46
- // read the old file to be converted
49
+ // Read the file to be converted
47
50
using ReaderType = itk::ImageFileReader< ImageType >;
48
51
ReaderType::Pointer reader = ReaderType::New ();
49
52
reader->SetFileName ( inputImage );
@@ -54,7 +57,7 @@ int main( int argc, char* argv[] )
54
57
using FilterType = itk::AdditiveGaussianNoiseImageFilter< ImageType, ImageType >;
55
58
FilterType::Pointer filter = FilterType::New ();
56
59
filter->SetInput ( reader->GetOutput () );
57
- filter->SetMean ( mean ); // set the mean
60
+ filter->SetMean ( mean ); // Set the mean
58
61
filter->SetStandardDeviation ( deviation ); // Set the standard deviation
59
62
60
63
// Set the writer to save file
@@ -63,7 +66,7 @@ int main( int argc, char* argv[] )
63
66
writer->SetFileName ( outputImage );
64
67
writer->SetInput ( filter->GetOutput () );
65
68
66
- // Write the output image
69
+ // Write the output image
67
70
try
68
71
{
69
72
writer->Update ();
0 commit comments