7 #include "PlusConfigure.h" 12 #include "vtkImageCast.h" 13 #include <vtkIntArray.h> 15 #include <vtkObjectFactory.h> 16 #include <vtkImageData.h> 17 #include <vtkDoubleArray.h> 18 #include <vtkTimerLog.h> 29 #define MKL_FREE_IF_NULL(var) \ 77 output->SetExtent(input->GetExtent());
78 #if (VTK_MAJOR_VERSION < 6) 79 output->SetScalarType(input->GetScalarType());
80 output->SetNumberOfScalarComponents(input->GetNumberOfScalarComponents());
81 output->AllocateScalars();
83 output->AllocateScalars(input->GetScalarType(), input->GetNumberOfScalarComponents());
86 int* inputExtent = input->GetExtent();
87 if ((inputExtent[1] - inputExtent[0] + 1) != this->
FrameSize[0] || (inputExtent[3] - inputExtent[2] + 1) != this->
FrameSize[1])
89 this->
FrameSize[0] = static_cast<unsigned int>(inputExtent[1] - inputExtent[0] + 1);
90 this->
FrameSize[1] = static_cast<unsigned int>(inputExtent[3] - inputExtent[2] + 1);
100 int* dims = input->GetDimensions();
105 vtkSmartPointer<vtkTimerLog> timer = vtkSmartPointer<vtkTimerLog>::New();
108 for (
unsigned int sliceIdx = inputExtent[4]; sliceIdx <= inputExtent[5]; ++sliceIdx)
110 LOG_INFO(
"---------------");
112 double* inputSlicePtr = static_cast<double*>(input->GetScalarPointer(0, 0, sliceIdx));
113 double* outputSlicePtr = static_cast<double*>(output->GetScalarPointer(0, 0, sliceIdx));
122 LOG_INFO(
"Conv2 1: " << timer->GetElapsedTime());
127 LOG_INFO(
"Normalize 1: " << timer->GetElapsedTime());
133 LOG_INFO(
"Conv2 2: " << timer->GetElapsedTime());
140 int i, pixelIdx,
x,
y;
142 #pragma omp parallel for reduction(+:sumG,sumGI, sumHist), private(i, x, pixelIdx) 144 for (
y = 0;
y < ny; ++
y)
146 for (
x = 0;
x < nx; ++
x)
148 pixelIdx =
x +
y * nx;
170 for (
i =
y;
i < ny; ++
i)
186 LOG_INFO(
"Main processing: " << timer->GetElapsedTime());
193 LOG_INFO(
"Normalize 2x: " << timer->GetElapsedTime());
200 LOG_INFO(
"Non-linear transform: " << timer->GetElapsedTime());
204 Normalize(outputSlicePtr, sliceSize,
false, 255);
206 LOG_INFO(
"Normalize 3: " << timer->GetElapsedTime());
245 for (
double x = -intervall;
x <= intervall; ++
x)
247 for (
double y = -intervall;
y <= intervall; ++
y)
285 int inputShape[] = {nx, ny};
286 int kernelShape[] = {kx, ky};
287 int resultShape[] = {nx + kx - 1, ny + ky - 1};
290 int status = vsldConvNewTask(&task, VSL_CONV_MODE_AUTO, 2, inputShape, kernelShape, resultShape);
292 status = vsldConvExec(task, inputBuffer, NULL, kernelBuffer, NULL, tempBuffer, NULL);
293 vslConvDeleteTask(&task);
295 vtkSmartPointer<vtkTimerLog> timer = vtkSmartPointer<vtkTimerLog>::New();
297 ResizeMatrix(tempBuffer, outputBuffer, kx, ky, nx + kx - 1, ny + ky - 1);
299 LOG_INFO(
"Resizematrix: " << timer->GetElapsedTime());
305 int xStart = (xClipping + 2 - 1) / 2 - 1;
306 int yStart = (yClipping + 2 - 1) / 2 - 1;
307 int xStop = xInputSize - xStart;
308 int yStop = yInputSize - yStart;
311 for (
int y = 0;
y < yInputSize; ++
y)
313 for (
int x = 0;
x < xInputSize; ++
x)
315 if (
x >= xStart && x < xStop && y >= yStart &&
y < yStop)
317 outputBuffer[idx] = inputBuffer[
x +
y * xInputSize];
327 double maxPixelValue = 0;
328 for (
int i = 0;
i < size; ++
i)
330 if (buffer[
i] > maxPixelValue)
332 maxPixelValue = buffer[
i];
335 return maxPixelValue;
345 for (
int i = 0;
i < size; ++
i)
347 buffer[
i] = buffer[
i] / maxPixelValue;
352 for (
int i = 0;
i < size; ++
i)
354 buffer[
i] = maxValue - buffer[
i] / maxPixelValue;
double * MklLaplacianOfGaussianBufferTemp
double GetMaxPixelValue(const double *buffer, int size)
double * MklLaplacianOfGaussianBuffer
void Normalize(double *buffer, int size, bool doInverse, double maxValue=1.0)
double * MklShadowValueBuffer
double * MklGaussianKernel
This class computes bone surface probability by dynamic programming.
vtkPlusForoughiBoneSurfaceProbability()
double * MklReflectionNumberBuffer
void ResizeMatrix(const double *inputBuffer, double *outputBuffer, int xClipping, int yClipping, int xInputSize, int yInputSize)
double * MklLaplacianKernel
virtual void SimpleExecute(vtkImageData *input, vtkImageData *output)
void Conv2(const double *inputBuffer, const double *kernelBuffer, double *tempBuffer, double *outputBuffer, int nx, int ny, int kx, int ky)
double * MklGaussianBuffer
virtual ~vtkPlusForoughiBoneSurfaceProbability()
Direction vectors of rods y
#define MKL_FREE_IF_NULL(var)
double * MklGaussianBufferTemp
bool KernelUpdateRequested
vtkStandardNewMacro(vtkPlusForoughiBoneSurfaceProbability)