MCPcopy Create free account
hub / github.com/Kitware/VTK / vtkImageNormalizeExecute

Function vtkImageNormalizeExecute

Imaging/General/vtkImageNormalize.cxx:45–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43// out of extent.
44template <class T>
45void vtkImageNormalizeExecute(
46 vtkImageNormalize* self, vtkImageData* inData, vtkImageData* outData, int outExt[6], int id, T*)
47{
48 vtkImageIterator<T> inIt(inData, outExt);
49 vtkImageProgressIterator<float> outIt(outData, outExt, self, id);
50 int idxC, maxC;
51 float sum;
52 T* inVect;
53
54 // find the region to loop over
55 maxC = inData->GetNumberOfScalarComponents();
56
57 // Loop through output pixels
58 while (!outIt.IsAtEnd())
59 {
60 T* inSI = inIt.BeginSpan();
61 float* outSI = outIt.BeginSpan();
62 float* outSIEnd = outIt.EndSpan();
63 while (outSI != outSIEnd)
64 {
65 // save the start of the vector
66 inVect = inSI;
67
68 // compute the magnitude.
69 sum = 0.0;
70 for (idxC = 0; idxC < maxC; idxC++)
71 {
72 sum += static_cast<float>(*inSI) * static_cast<float>(*inSI);
73 inSI++;
74 }
75 if (sum > 0.0)
76 {
77 sum = 1.0 / sqrt(sum);
78 }
79
80 // now divide to normalize.
81 for (idxC = 0; idxC < maxC; idxC++)
82 {
83 *outSI = static_cast<float>(*inVect) * sum;
84 inVect++;
85 outSI++;
86 }
87 }
88 inIt.NextSpan();
89 outIt.NextSpan();
90 }
91}
92
93//------------------------------------------------------------------------------
94// This method contains a switch statement that calls the correct

Callers 1

ThreadedExecuteMethod · 0.85

Calls 4

NextSpanMethod · 0.80
sqrtFunction · 0.50
IsAtEndMethod · 0.45

Tested by

no test coverage detected