MCPcopy Create free account
hub / github.com/SimpleITK/SimpleITK / FixNonZeroIndex

Function FixNonZeroIndex

Code/BasicFilters/include/sitkImageFilter.h:59–89  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57 virtual ~ImageFilter() = 0;
58
59protected:
60 // Simple ITK must use a zero based index
61 template <class TImageType>
62 static void
63 FixNonZeroIndex(TImageType * img)
64 {
65 assert(img);
66
67 typename TImageType::RegionType r = img->GetLargestPossibleRegion();
68 typename TImageType::IndexType idx = r.GetIndex();
69
70 for (unsigned int i = 0; i < TImageType::ImageDimension; ++i)
71 {
72
73 if (idx[i] != 0)
74 {
75 // if any of the indicies are non-zero, then just fix it
76 typename TImageType::PointType o;
77 img->TransformIndexToPhysicalPoint(idx, o);
78 img->SetOrigin(o);
79
80 idx.Fill(0);
81 r.SetIndex(idx);
82
83 // Need to set the buffered region to match largest
84 img->SetRegions(r);
85
86 return;
87 }
88 }
89 }
90
91 /** Verify the dimension of image1 matches the dimension of
92 * image2, and if not then an exception is thrown.

Callers

nothing calls this directly

Calls 2

SetOriginMethod · 0.45

Tested by

no test coverage detected