24 #ifndef UTL_MAX_THREADS 25 #define UTL_MAX_THREADS 8 64 template <
class PixelType>
66 ReadVectorImage (
const std::string& filename, SmartPointer<VectorImage<PixelType,3> > &image,
const std::string& printInfo=
"Reading Image:" )
71 itk::ReadImage<VectorImageType>(filename, image, printInfo);
74 typedef itk::Image<PixelType, 4> MultiVolumeImageType;
75 typename MultiVolumeImageType::Pointer MultiVolumeImage;
76 itk::ReadImage<MultiVolumeImageType>(filename, MultiVolumeImage, printInfo);
79 typename MultiVolumeToVectorFilter::Pointer filter = MultiVolumeToVectorFilter::New();
80 filter->SetInput(MultiVolumeImage);
82 image = filter->GetOutput();
113 itk::VariableLengthVector<T>
116 itk::VariableLengthVector<T> v(vec.
Size());
117 for (
int i = 0; i < vec.
Size(); i += 1 )
127 for (
int i = 0; i < vec.GetSize(); i += 1 )
170 inline utl_shared_ptr<NDArray<T,2> >
174 int numberOfBasisFunctions = (rank + 1)*(rank + 2)/2;
175 int numberOfDirections = grad.
Rows();
184 utl_shared_ptr<NDArray<T,2> > BMatrix (
new NDArray<T,2>(numberOfDirections, numberOfBasisFunctions));
188 for (
unsigned int k = 0; k < numberOfDirections; k++ )
191 for (
int l = 0; l <= rank; l += 2 )
192 for (
int m = -l; m <= l; m++ )
245 template <
class Po
intsContainer,
class VnlValueType>
250 typedef typename PointsContainer::ConstIterator PointsIterator;
251 typedef typename PointsContainer::Element PointType;
253 const unsigned int pointDimension = PointType::PointDimension;
254 unsigned int numberOfPoints = points.Size();
255 if (numberOfPoints==0)
258 matrix.
ReSize(numberOfPoints, pointDimension);
259 PointsIterator iterator = points.Begin();
260 PointsIterator end = points.End();
262 unsigned int count=0;
263 while( iterator != end )
265 PointType orientation = iterator.Value();
266 for (
unsigned int k=0; k<pointDimension; k++)
267 matrix(count,k) = orientation[k];
273 template <
class VnlValueType,
class Po
intsContainer>
278 typedef typename PointsContainer::Element PointType;
280 const unsigned int pointDimension = PointType::PointDimension;
281 utlGlobalException(pointDimension!=matrix.Columns(),
"wrong size of matrix or point dimension. pointDimension="<< pointDimension <<
", matrix.Columns()="<<matrix.Columns());
283 for (
int i = 0; i < matrix.Rows(); i += 1 )
286 for (
int j = 0; j < matrix.Columns(); j += 1 )
288 point[j] = matrix(i,j);
290 points.InsertElement(i, point);
302 mkl_domain_set_num_threads ( NUM_THREADS, MKL_DOMAIN_ALL );
303 mkl_set_num_threads(NUM_THREADS);
315 #ifdef UTL_USE_OPENMP 319 omp_set_num_threads(NUM_THREADS);
NDArray is a N-Dimensional array class (row-major, c version)
NDArray<T,1> is a vector class which uses blas mkl.
void PointsContainerToUtlMatrix(const PointsContainer &points, utl::NDArray< VnlValueType, 2 > &matrix)
void ReadVectorImage(const std::string &filename, SmartPointer< VectorImage< PixelType, 3 > > &image, const std::string &printInfo="Reading Image:")
#define utlException(cond, expout)
bool IsFileExist(const std::string &file)
void UtlMatrixToPointsContainer(const NDArray< VnlValueType, 2 > &matrix, PointsContainer &points)
NDArray<T,2> is a row-major matrix.
bool ReSize(const ShapeType &shape)
convert Image<TInputPixelType, VImageDimension+1> to VectorImage<TOutputPixelType, VImageDimension>
itk::VariableLengthVector< T > UtlVectorToVariableLengthVector(const NDArray< T, 1 > &vec)
NDArray< T, 2 > CartesianToSpherical(const NDArray< T, 2 > &in)
std::shared_ptr< NDArray< T, 2 > > ComputeSHMatrix(const unsigned int rank, const NDArray< T, 2 > &grad, const int mode)
const T & min(const T &a, const T &b)
Return the minimum between a and b.
#define utlGlobalException(cond, expout)
NDArray< T, 1 > VariableLengthVectorToUtlVector(const itk::VariableLengthVector< T > &vec)
static int InitializeOpenMP(const int numThreads)
Generate complex and real Spherical Harmonic Basis.
static void InitializeThreadedLibraries(const int numThreads)
bool IsVectorImage(const std::string &filename)
itk::VectorImage< ScalarType, 3 > VectorImageType
static int InitializeMKL(const int numThreads)