MCPcopy Create free account
hub / github.com/MITK/MITK / GenerateImageFromReference

Function GenerateImageFromReference

Modules/Core/include/mitkImageGenerator.h:112–140  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

110 */
111 template <typename TPixelType>
112 static mitk::Image::Pointer GenerateImageFromReference(mitk::Image::Pointer reference, TPixelType fill_value)
113 {
114 mitk::Image::Pointer output = mitk::Image::New();
115 mitk::PixelType output_type = MakeScalarPixelType<TPixelType>();
116
117 // all metadata (except type) come from reference image
118 output->SetGeometry(reference->GetGeometry());
119 output->Initialize(output_type, reference->GetDimension(), reference->GetDimensions());
120
121 // get a pointer to the image buffer to write into
122 TPixelType *imageBuffer = nullptr;
123 try
124 {
125 mitk::ImageWriteAccessor writeAccess(output);
126 imageBuffer = static_cast<TPixelType *>(writeAccess.GetData());
127 }
128 catch (...)
129 {
130 MITK_ERROR << "Write access not granted on mitk::Image.";
131 }
132
133 // fill the buffer with the specified value
134 for (unsigned int i = 0; i < output->GetVolumeData(0)->GetSize(); i++)
135 {
136 imageBuffer[i] = fill_value;
137 }
138
139 return output;
140 }
141
142 /**
143 * \brief Generates a random image with the defined size and spacing.

Callers

nothing calls this directly

Calls 9

GetGeometryMethod · 0.80
GetDimensionsMethod · 0.80
NewFunction · 0.70
SetGeometryMethod · 0.45
InitializeMethod · 0.45
GetDimensionMethod · 0.45
GetDataMethod · 0.45
GetSizeMethod · 0.45
GetVolumeDataMethod · 0.45

Tested by

no test coverage detected