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,38 +47,39 @@ 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
itk::Size<2 > size;
54
57
size.Fill (100 );
55
58
56
- itk::ImageRegion<2> region(start,size);
59
+ itk::ImageRegion<2 > region (start, size);
57
60
58
61
image->SetRegions (region);
59
62
image->Allocate ();
60
63
image->FillBuffer (0 );
61
64
62
65
// Create a line pixels
63
- for(unsigned int i = 40; i < 60; ++i)
64
- {
66
+ for (unsigned int i = 40 ; i < 60 ; ++i)
67
+ {
65
68
itk::Index<2 > pixel;
66
69
pixel.Fill (i);
67
70
image->SetPixel (pixel, 255 );
68
- }
71
+ }
69
72
70
73
// Create another line of pixels
71
- for(unsigned int i = 10; i < 20; ++i)
72
- {
74
+ for (unsigned int i = 10 ; i < 20 ; ++i)
75
+ {
73
76
itk::Index<2 > pixel;
74
77
pixel[0 ] = 10 ;
75
78
pixel[1 ] = i;
76
79
image->SetPixel (pixel, 255 );
77
- }
80
+ }
78
81
79
- using WriterType = itk::ImageFileWriter< UnsignedCharImageType >;
82
+ using WriterType = itk::ImageFileWriter<UnsignedCharImageType>;
80
83
auto writer = WriterType::New ();
81
84
writer->SetFileName (" input.png" );
82
85
writer->SetInput (image);
0 commit comments