Commit e0db3ed9 authored by David Gobbi's avatar David Gobbi
Browse files

ENH: Remove ops from the inner loops of vtkImageHistogram.

Change-Id: I65e41c7675d353048dcf45766a9e64b44fda7888
parent 4763f4f8
......@@ -331,16 +331,20 @@ void vtkImageHistogramExecuteRange(
{
inPtr = inIter.BeginSpan();
T *inPtrEnd = inIter.EndSpan();
// iterate over all voxels in the span
while (inPtr != inPtrEnd)
if (inPtr != inPtrEnd)
{
T x = inPtr[c];
int n = static_cast<int>((inPtrEnd - inPtr)/nc);
inPtr += c;
do
{
T x = *inPtr;
xmin = (xmin < x ? xmin : x);
xmax = (xmax > x ? xmax : x);
xmin = (xmin < x ? xmin : x);
xmax = (xmax > x ? xmax : x);
inPtr += nc;
inPtr += nc;
}
while (--n);
}
}
inIter.NextSpan();
......@@ -385,21 +389,27 @@ void vtkImageHistogramExecute(
T *inPtrEnd = inIter.EndSpan();
// iterate over all voxels in the span
while (inPtr != inPtrEnd)
if (inPtr != inPtrEnd)
{
double x = inPtr[c];
int n = static_cast<int>((inPtrEnd - inPtr)/nc);
inPtr += c;
do
{
double x = *inPtr;
x += xshift;
x *= xscale;
x += xshift;
x *= xscale;
x = (x > xmin ? x : xmin);
x = (x < xmax ? x : xmax);
x = (x > xmin ? x : xmin);
x = (x < xmax ? x : xmax);
int xi = static_cast<int>(x + 0.5);
int xi = static_cast<int>(x + 0.5);
outPtr[xi]++;
outPtr[xi]++;
inPtr += nc;
inPtr += nc;
}
while (--n);
}
}
inIter.NextSpan();
......@@ -440,8 +450,7 @@ void vtkImageHistogramExecuteInt(
inPtr += c;
do
{
int ix = static_cast<int>(*inPtr);
outPtr[ix]++;
outPtr[*inPtr]++;
inPtr += nc;
}
while (--n);
......@@ -451,6 +460,20 @@ void vtkImageHistogramExecuteInt(
}
}
// no-op version for float
void vtkImageHistogramExecuteInt(
vtkImageHistogram *, vtkImageData *, vtkImageStencilData *,
float *, int [6], vtkIdType *, int, int)
{
}
// no-op version for double
void vtkImageHistogramExecuteInt(
vtkImageHistogram *, vtkImageData *, vtkImageStencilData *,
double *, int [6], vtkIdType *, int, int)
{
}
//----------------------------------------------------------------------------
void vtkImageHistogramGenerateImage(
vtkIdType *histogram, int nx,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment