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

Method UpdateImageInformationFromImageIO

Code/IO/src/sitkImageFileReader.cxx:135–185  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

133
134
135void
136ImageFileReader ::UpdateImageInformationFromImageIO(const itk::ImageIOBase * iobase)
137{
138 PixelIDValueType pixelType;
139 this->GetPixelIDFromImageIO(iobase, pixelType, m_Dimension);
140
141 std::vector<double> direction(m_Dimension * m_Dimension);
142
143 std::vector<double> origin(m_Dimension);
144 std::vector<double> spacing(m_Dimension);
145 std::vector<uint64_t> size(m_Dimension);
146 for (unsigned int i = 0; i < m_Dimension; ++i)
147 {
148 origin[i] = iobase->GetOrigin(i);
149 spacing[i] = iobase->GetSpacing(i);
150 size[i] = iobase->GetDimensions(i);
151 for (unsigned int col = 0; col < m_Dimension; ++col)
152 {
153 direction[i * m_Dimension + col] = iobase->GetDirection(col)[i];
154 }
155 }
156
157 // release functions bound to old meta data dictionary
158 if (m_MetaDataDictionary.get())
159 {
160 this->m_pfGetMetaDataKeys = nullptr;
161 this->m_pfHasMetaDataKey = nullptr;
162 this->m_pfGetMetaData = nullptr;
163 }
164
165 this->m_MetaDataDictionary = std::make_unique<MetaDataDictionary>(iobase->GetMetaDataDictionary());
166
167 m_PixelType = static_cast<PixelIDValueEnum>(pixelType);
168
169 // Use the number of components as reported by the itk::Image
170 m_NumberOfComponents = iobase->GetNumberOfComponents();
171
172 using std::swap;
173 swap(direction, m_Direction);
174 swap(origin, m_Origin);
175 swap(spacing, m_Spacing);
176 swap(size, m_Size);
177
178 this->m_pfGetMetaDataKeys = [capture0 = this->m_MetaDataDictionary.get()] { return capture0->GetKeys(); };
179 this->m_pfHasMetaDataKey = [capture0 = this->m_MetaDataDictionary.get()](auto && PH1) {
180 return capture0->HasKey(std::forward<decltype(PH1)>(PH1));
181 };
182 this->m_pfGetMetaData = [capture0 = this->m_MetaDataDictionary.get()](auto && PH1) {
183 return GetMetaDataDictionaryCustomCast::CustomCast(capture0, std::forward<decltype(PH1)>(PH1));
184 };
185}
186
187PixelIDValueEnum
188ImageFileReader ::GetPixelID() const

Callers 2

ReadImageInformationMethod · 0.95
ExecuteMethod · 0.80

Calls 5

GetPixelIDFromImageIOMethod · 0.80
GetOriginMethod · 0.80
GetSpacingMethod · 0.80
GetDirectionMethod · 0.80
GetNumberOfComponentsMethod · 0.80

Tested by

no test coverage detected