15
15
* limitations under the License.
16
16
*
17
17
*=========================================================================*/
18
- /*
18
+
19
19
#include " itkImage.h"
20
20
#include " itkImageFileWriter.h"
21
21
#include " itkSimpleContourExtractorImageFilter.h"
22
22
#include " itkImageRegionIterator.h"
23
23
24
24
using UnsignedCharImageType = itk::Image<unsigned char , 2 >;
25
25
26
- static void CreateImage(UnsignedCharImageType::Pointer image);
26
+ static void
27
+ CreateImage (UnsignedCharImageType::Pointer image);
27
28
28
- int main()
29
+ int
30
+ main ()
29
31
{
30
32
auto image = UnsignedCharImageType::New ();
31
33
CreateImage (image);
32
34
33
- using SimpleContourExtractorImageFilterType = itk::SimpleContourExtractorImageFilter <UnsignedCharImageType, UnsignedCharImageType>;
34
- SimpleContourExtractorImageFilterType::Pointer contourFilter
35
- = SimpleContourExtractorImageFilterType::New();
35
+ using SimpleContourExtractorImageFilterType =
36
+ itk::SimpleContourExtractorImageFilter<UnsignedCharImageType, UnsignedCharImageType>;
37
+ SimpleContourExtractorImageFilterType::Pointer contourFilter = SimpleContourExtractorImageFilterType::New ();
36
38
contourFilter->SetInput (image);
37
39
contourFilter->Update ();
38
40
39
- using WriterType = itk::ImageFileWriter< UnsignedCharImageType >;
41
+ using WriterType = itk::ImageFileWriter<UnsignedCharImageType>;
40
42
auto writer = WriterType::New ();
41
43
writer->SetFileName (" output.png" );
42
44
writer->SetInput (contourFilter->GetOutput ());
@@ -45,36 +47,37 @@ int main()
45
47
return EXIT_SUCCESS;
46
48
}
47
49
48
- void CreateImage(UnsignedCharImageType::Pointer image)
50
+ void
51
+ CreateImage (UnsignedCharImageType::Pointer image)
49
52
{
50
53
// Create an image
51
54
itk::Index<2 > start{};
52
55
53
56
auto size = itk::Size<2 >::Filled (100 );
54
57
55
- itk::ImageRegion<2> region(start,size);
58
+ itk::ImageRegion<2 > region (start, size);
56
59
57
60
image->SetRegions (region);
58
61
image->Allocate ();
59
62
image->FillBuffer (0 );
60
63
61
64
// Create a line pixels
62
- for(unsigned int i = 40; i < 60; ++i)
63
- {
65
+ for (unsigned int i = 40 ; i < 60 ; ++i)
66
+ {
64
67
auto pixel = itk::Index<2 >::Filled (i);
65
68
image->SetPixel (pixel, 255 );
66
- }
69
+ }
67
70
68
71
// Create another line of pixels
69
- for(unsigned int i = 10; i < 20; ++i)
70
- {
72
+ for (unsigned int i = 10 ; i < 20 ; ++i)
73
+ {
71
74
itk::Index<2 > pixel;
72
75
pixel[0 ] = 10 ;
73
76
pixel[1 ] = i;
74
77
image->SetPixel (pixel, 255 );
75
- }
78
+ }
76
79
77
- using WriterType = itk::ImageFileWriter< UnsignedCharImageType >;
80
+ using WriterType = itk::ImageFileWriter<UnsignedCharImageType>;
78
81
auto writer = WriterType::New ();
79
82
writer->SetFileName (" input.png" );
80
83
writer->SetInput (image);
0 commit comments