STIR  6.2.0
Modules | Files | Classes | Functions
Items relating to vectors and (multi-dimensional) arrays
Collaboration diagram for Items relating to vectors and (multi-dimensional) arrays:

Modules

 Implementation details used by Array classes
 
 Functions that implement IO for Array objects
 

Files

file  Array.cxx
 non-inline implementations for the Array class
 
file  ArrayFilter1DUsingConvolution.cxx
 Implementations for class stir::ArrayFilter1DUsingConvolution.
 
file  ArrayFilter1DUsingConvolutionSymmetricKernel.cxx
 Implementations for class stir::ArrayFilter1DUsingConvolutionSymmetricKernel.
 
file  ArrayFilterUsingRealDFTWithPadding.cxx
 Implementation of class stir::ArrayFilterUsingRealDFTWithPadding.
 
file  centre_of_gravity.cxx
 Implementations of centre_of_gravity.h.
 
file  IndexRange.cxx
 implementations for the stir::IndexRange class
 
file  MaximalArrayFilter3D.cxx
 Applies the dilation filter (i.e. voxel=max(neighbours))
 
file  MedianArrayFilter3D.cxx
 Implementations for class stir::MedianArrayFilter3D.
 
file  MinimalArrayFilter3D.cxx
 Applies the erosion filter (i.e. voxel=min(neighbours))
 
file  SeparableArrayFunctionObject.cxx
 Implementations for stir::SeparableArrayFunctionObject.
 
file  SeparableGaussianArrayFilter.cxx
 Implementations for class stir::SeparableGaussianArrayFilter.
 
file  SeparableMetzArrayFilter.cxx
 Implementations for class stir::SeparableMetzArrayFilter.
 
file  Array.h
 defines the Array class for multi-dimensional (numeric) arrays
 
file  Array.inl
 inline implementations for the stir::Array class
 
file  Array_complex_numbers.h
 defines additional numerical operations for arrays of complex numbers
 
file  array_index_functions.h
 a variety of useful functions for indexing stir::Array objects
 
file  array_index_functions.inl
 implementation of functions in stir/array_index_functions.h
 
file  ArrayFilter1DUsingConvolution.h
 Declaration of class stir::ArrayFilter1DUsingConvolution.
 
file  ArrayFilter1DUsingConvolutionSymmetricKernel.h
 Declaration of class stir::ArrayFilter1DUsingConvolutionSymmetricKernel.
 
file  ArrayFilterUsingRealDFTWithPadding.h
 Declaration of class stir::ArrayFilterUsingRealDFTWithPadding.
 
file  ArrayFunction.h
 This include file provides some additional functionality for stir::Array objects.
 
file  ArrayFunction.inl
 Implementations for ArrayFunction.h.
 
file  ArrayFunctionObject.h
 Declaration of class stir::ArrayFunctionObject.
 
file  ArrayFunctionObject_1ArgumentImplementation.h
 Declaration of class stir::ArrayFunctionObject_1ArgumentImplementation.
 
file  ArrayFunctionObject_2ArgumentImplementation.h
 Declaration of class stir::ArrayFunctionObject_2ArgumentImplementation.
 
file  assign_to_subregion.h
 declares the stir::assign_to_subregion function
 
file  assign_to_subregion.inl
 implementation of the stir::assign_to_subregion function
 
file  BoundaryConditions.h
 Declaration of class stir::BoundaryConditions.
 
file  centre_of_gravity.h
 This file contains functions to compute the centre of gravity of arrays and images.
 
file  convert_array.h
 This file declares the stir::convert_array functions. This is a function to convert stir::Array objects to a different numeric type.
 
file  convert_array.inl
 implementation of stir::convert_array
 
file  convert_range.h
 This file declares the stir::convert_range and stir::find_scale_factor functions.
 
file  convert_range.inl
 implementation of stir::convert_range
 
file  FullArrayIterator.h
 This file declares the stir::FullArrayIterator class.
 
file  FullArrayIterator.inl
 inline implementations for stir::FullArrayIterator.
 
file  IndexRange.inl
 inline definitions for the IndexRange class
 
file  IndexRange2D.h
 This file declares the class stir::IndexRange2D.
 
file  IndexRange2D.inl
 inline implementations for stir::IndexRange2D.
 
file  IndexRange3D.h
 This file declares the class stir::IndexRange3D.
 
file  IndexRange3D.inl
 inline implementations for stir::IndexRange3D.
 
file  IndexRange4D.h
 This file declares the class stir::IndexRange4D.
 
file  IndexRange4D.inl
 inline implementations for stir::IndexRange4D.
 
file  make_array.h
 Declaration of functions for constructing arrays stir::make_1d_array etc.
 
file  make_array.inl
 Implementation of functions for constructing arrays stir::make_1d_array etc.
 
file  MaximalArrayFilter3D.h
 Applies the dilation filter (i.e. voxel=max(neighbours))
 
file  MedianArrayFilter3D.h
 Declaration of class stir::MedianArrayFilter3D.
 
file  MinimalArrayFilter3D.h
 Applies the erosion filter (i.e. voxel=min(neighbours))
 
file  NumericVectorWithOffset.inl
 inline implementations for stir::NumericVectorWithOffset
 
file  SeparableArrayFunctionObject.h
 Declaration of class stir::SeparableArrayFunctionObject.
 
file  SeparableMetzArrayFilter.h
 Declaration of class stir::SeparableMetzArrayFilter.
 
file  VectorWithOffset.h
 defines the stir::VectorWithOffset class
 
file  VectorWithOffset.inl
 inline implementations of stir::VectorWithOffset
 
file  test_Array.cxx
 tests for the stir::Array class
 

Classes

class  stir::Array< num_dimensions, elemT >
 This class defines multi-dimensional (numeric) arrays. More...
 
class  stir::ArrayFilter1DUsingConvolution< elemT >
 This class implements convolution of a 1D array with an arbitrary (i.e. potentially non-symmetric) kernel. More...
 
class  stir::ArrayFilter1DUsingConvolutionSymmetricKernel< elemT >
 This class implements convolution of a 1D array with a symmetric kernel. More...
 
class  stir::ArrayFilterUsingRealDFTWithPadding< num_dimensions, elemT >
 This class implements convolution of an array of real numbers with an arbitrary (i.e. potentially non-symmetric) kernel using DFTs. More...
 
class  stir::ArrayFunctionObject< num_dimensions, elemT >
 A class for operations on n-dimensional Arrays. More...
 
class  stir::ArrayFunctionObject_1ArgumentImplementation< num_dimensions, elemT >
 A convenience class for children of ArrayFunctionObject. It implements the 2 argument operator() in terms of the in-place version. More...
 
class  stir::ArrayFunctionObject_2ArgumentImplementation< num_dimensions, elemT >
 A convenience class for children of ArrayFunctionObject. It implements the in-place operator() in terms of the 2 argument version. More...
 
class  stir::BoundaryConditions
 Preliminary class to specify boundary conditions for filters. More...
 
class  stir::FullArrayIterator< topleveliterT, restiterT, elemT, _Ref, _Ptr >
 Class FullArrayIterator implements (forward) iterators that go through all elements of an Array. More...
 
class  stir::IndexRange< num_dimensions >
 This class defines ranges which can be 'irregular'. More...
 
class  stir::IndexRange2D
 a 'convenience' class for 2D index ranges. More...
 
class  stir::IndexRange3D
 a 'convenience' class for 3D index ranges. Provides an easier constructor for regular ranges. More...
 
class  stir::IndexRange4D
 A convenience class for 4D index ranges. More...
 
class  stir::MaximalArrayFilter3D< elemT >
 Implements erosion on 3D arrays. More...
 
class  stir::MedianArrayFilter3D< elemT >
 Implements median filtering on 3D arrays. More...
 
class  stir::MinimalArrayFilter3D< elemT >
 Implements erosion on 3D arrays. More...
 
class  stir::NumericVectorWithOffset< T, elemT >
 like VectorWithOffset, but with changes in various numeric operators More...
 
class  stir::SeparableArrayFunctionObject< num_dimensions, elemT >
 This class implements an n -dimensional ArrayFunctionObject whose operation is separable. More...
 
class  stir::SeparableGaussianArrayFilter< num_dimensions, elemT >
 Separable Gaussian filtering in n - dimensions. More...
 
class  stir::SeparableMetzArrayFilter< num_dimensions, elemT >
 Separable Metz filtering in n - dimensions. More...
 
class  stir::VectorWithOffset< T >
 A templated class for vectors, but with indices starting not from 0. More...
 
class  stir::SeparableGaussianArrayFilterTests
 Tests SeparableGaussianArrayFilter functionalityCurrently only very basic tests on normalisation. More...
 
class  stir::SeparableMetzArrayFilterTests
 Tests SeparableMetzArrayFilter functionalityCurrently only very basic tests on normalisation. More...
 

Functions

template<class elemT >
Array< 1, elemT > & stir::in_place_log (Array< 1, elemT > &v)
 Replace elements by their logarithm, 1D version. More...
 
template<int num_dimensions, class elemT >
Array< num_dimensions, elemT > & stir::in_place_log (Array< num_dimensions, elemT > &v)
 apply log to each element of the multi-dimensional array More...
 
template<class elemT >
Array< 1, elemT > & stir::in_place_exp (Array< 1, elemT > &v)
 Replace elements by their exponentiation, 1D version. More...
 
template<int num_dimensions, class elemT >
Array< num_dimensions, elemT > & stir::in_place_exp (Array< num_dimensions, elemT > &v)
 apply exp to each element of the multi-dimensional array More...
 
template<class elemT >
Array< 1, elemT > & stir::in_place_abs (Array< 1, elemT > &v)
 Replace elements by their absolute value, 1D version. More...
 
template<int num_dimensions, class elemT >
Array< num_dimensions, elemT > & stir::in_place_abs (Array< num_dimensions, elemT > &v)
 store absolute value of each element of the multi-dimensional array More...
 
template<class T , class FUNCTION >
T & stir::in_place_apply_function (T &v, FUNCTION f)
 apply any function(object) to each element of the multi-dimensional array More...
 
template<int num_dim, typename elemT , typename FunctionObjectPtr >
void stir::in_place_apply_array_function_on_1st_index (Array< num_dim, elemT > &array, FunctionObjectPtr f)
 Apply a function object on all possible 1d arrays extracted by keeping all indices fixed, except the first one. More...
 
template<int num_dim, typename elemT , typename FunctionObjectPtr >
void stir::apply_array_function_on_1st_index (Array< num_dim, elemT > &out_array, const Array< num_dim, elemT > &in_array, FunctionObjectPtr f)
 apply any function(object) to each element of the multi-dimensional array, storing results in a different array More...
 
template<int num_dim, typename elemT , typename FunctionObjectPtrIter >
void stir::in_place_apply_array_functions_on_each_index (Array< num_dim, elemT > &array, FunctionObjectPtrIter start, FunctionObjectPtrIter stop)
 Apply a sequence of 1d array-function objects on every dimension of the input array. More...
 
template<int num_dim, typename elemT , typename FunctionObjectPtrIter >
void stir::apply_array_functions_on_each_index (Array< num_dim, elemT > &out_array, const Array< num_dim, elemT > &in_array, FunctionObjectPtrIter start, FunctionObjectPtrIter stop)
 Apply a sequence of 1d array-function objects on every dimension of the input array, store in output array. More...
 
template<int num_dim, typename elemT >
void stir::apply_array_functions_on_each_index (Array< num_dim, elemT > &out_array, const Array< num_dim, elemT > &in_array, ActualFunctionObjectPtrIter start, ActualFunctionObjectPtrIter stop)
 Apply a sequence of 1d array-function objects of a specific type on every dimension of the input array, store in output array. More...
 
template<typename elemT >
void stir::apply_array_functions_on_each_index (Array< 1, elemT > &out_array, const Array< 1, elemT > &in_array, ActualFunctionObjectPtrIter start, ActualFunctionObjectPtrIter stop)
 1d specialisation of above
 
template<typename elemT , typename FunctionObjectPtrIter >
void stir::apply_array_functions_on_each_index (Array< 1, elemT > &out_array, const Array< 1, elemT > &in_array, FunctionObjectPtrIter start, FunctionObjectPtrIter stop)
 1d specialisation for general function objects
 
template<class elemT >
void stir::assign_to_subregion (Array< 3, elemT > &input_array, const BasicCoordinate< 3, int > &mask_location, const BasicCoordinate< 3, int > &half_size, const elemT &value)
 assign a value to a sub-region of an array More...
 
template<class T >
stir::find_unweighted_centre_of_gravity_1d (const VectorWithOffset< T > &row)
 Compute centre of gravity of a vector but without dividing by its sum. More...
 
template<int num_dimensions, class T >
BasicCoordinate< num_dimensions, T > stir::find_unweighted_centre_of_gravity (const Array< num_dimensions, T > &)
 Compute centre of gravity of an Array but without dividing by its sum. More...
 
template<class T >
stir::find_unweighted_centre_of_gravity (const Array< 1, T > &)
 Compute centre of gravity of a 1D Array but without dividing by its sum. More...
 
template<int num_dimensions, class T >
BasicCoordinate< num_dimensions, T > stir::find_centre_of_gravity (const Array< num_dimensions, T > &)
 Compute centre of gravity of an Array. More...
 
template<class T >
void stir::find_centre_of_gravity_in_mm_per_plane (VectorWithOffset< CartesianCoordinate3D< float >> &allCoG, VectorWithOffset< T > &weights, const VoxelsOnCartesianGrid< T > &image)
 Computes centre of gravity for each plane. More...
 
template<class T >
CartesianCoordinate3D< float > stir::find_centre_of_gravity_in_mm (const VoxelsOnCartesianGrid< T > &image)
 Computes centre of gravity of an image. More...
 
template<int num_dimensions, class T1 , class T2 , class scaleT >
void stir::find_scale_factor (scaleT &scale_factor, const Array< num_dimensions, T1 > &data_in, const NumericInfo< T2 > info_for_out_type)
 A function that finds a scale factor to use when converting data to a new type. More...
 
template<int num_dimensions, class T1 , class T2 , class scaleT >
Array< num_dimensions, T2 > stir::convert_array (scaleT &scale_factor, const Array< num_dimensions, T1 > &data_in, const NumericInfo< T2 > info2)
 A function that returns a new Array (of the same dimension) with elements of type T2. More...
 
template<int num_dimensions, class T1 , class T2 , class scaleT >
void stir::convert_array (Array< num_dimensions, T2 > &data_out, scaleT &scale_factor, const Array< num_dimensions, T1 > &data_in)
 Converts the data_in Array to data_out (with elements of different types) such that data_in == data_out * scale_factor. More...
 
template<class InputIteratorT , class T2 , class scaleT >
void stir::find_scale_factor (scaleT &scale_factor, const InputIteratorT &begin, const InputIteratorT &end, const NumericInfo< T2 > info_for_out_type)
 A function that finds a scale factor to use when converting data to a new type. More...
 
template<class OutputIteratorT , class InputIteratorT , class scaleT >
void stir::convert_range (const OutputIteratorT &out_begin, scaleT &scale_factor, const InputIteratorT &in_begin, const InputIteratorT &in_end)
 Converts the data in the input range to the output range (with elements of different types) such that data_in == data_out * scale_factor. More...
 

Detailed Description

Function Documentation

◆ in_place_log() [1/2]

template<class elemT >
Array< 1, elemT > & stir::in_place_log ( Array< 1, elemT > &  v)
inline

Replace elements by their logarithm, 1D version.

◆ in_place_log() [2/2]

template<int num_dimensions, class elemT >
Array< num_dimensions, elemT > & stir::in_place_log ( Array< num_dimensions, elemT > &  v)
inline

apply log to each element of the multi-dimensional array

◆ in_place_exp() [1/2]

template<class elemT >
Array< 1, elemT > & stir::in_place_exp ( Array< 1, elemT > &  v)
inline

Replace elements by their exponentiation, 1D version.

Referenced by stir::BinNormalisationFromAttenuationImage::apply(), and stir::BinNormalisationFromAttenuationImage::undo().

◆ in_place_exp() [2/2]

template<int num_dimensions, class elemT >
Array< num_dimensions, elemT > & stir::in_place_exp ( Array< num_dimensions, elemT > &  v)
inline

apply exp to each element of the multi-dimensional array

◆ in_place_abs() [1/2]

template<class elemT >
Array< 1, elemT > & stir::in_place_abs ( Array< 1, elemT > &  v)
inline

Replace elements by their absolute value, 1D version.

Warning
The implementation does not work with complex numbers.

Referenced by stir::ReconstructionTests< target_type >::compare().

◆ in_place_abs() [2/2]

template<int num_dimensions, class elemT >
Array< num_dimensions, elemT > & stir::in_place_abs ( Array< num_dimensions, elemT > &  v)
inline

store absolute value of each element of the multi-dimensional array

Warning
The implementation does not work with complex numbers.

◆ in_place_apply_function()

template<class T , class FUNCTION >
T & stir::in_place_apply_function ( T &  v,
FUNCTION  f 
)
inline

apply any function(object) to each element of the multi-dimensional array

Each element will be replaced by

elem = f(elem);

Requires that type T has begin_all() and end_all() functions.

Referenced by stir::ScatterEstimation::process_data().

◆ in_place_apply_array_function_on_1st_index()

template<int num_dim, typename elemT , typename FunctionObjectPtr >
void stir::in_place_apply_array_function_on_1st_index ( Array< num_dim, elemT > &  array,
FunctionObjectPtr  f 
)
inline

Apply a function object on all possible 1d arrays extracted by keeping all indices fixed, except the first one.

For the 2d case, this amounts to applying a function on all columns of the matrix.

For a 3d case, the following pseudo-code illustrates what happens.

for all i2,i3
{
for all i
{
a[i] = array[i][i2][i3];
}
(*f)(a);
for all i
{
array[i][i2][i3] = a[i];
}
}
Warning
The array has to be regular.
Todo:

Add a 1D specialisation as the current implementation would be really inefficient in this case.

Add a specialisation such that this function would handle function objects and (smart) pointers to function objects. At the moment, it's only the latter.

References stir::VectorWithOffset< Array< num_dimensions - 1, elemT > >::get_max_index(), stir::VectorWithOffset< Array< num_dimensions - 1, elemT > >::get_min_index(), and stir::Array< num_dimensions, elemT >::is_regular().

Referenced by stir::in_place_apply_array_functions_on_each_index().

◆ apply_array_function_on_1st_index()

template<int num_dim, typename elemT , typename FunctionObjectPtr >
void stir::apply_array_function_on_1st_index ( Array< num_dim, elemT > &  out_array,
const Array< num_dim, elemT > &  in_array,
FunctionObjectPtr  f 
)
inline

apply any function(object) to each element of the multi-dimensional array, storing results in a different array

Warning
Both in_array and out_array have to have regular ranges. Moreover, they have to have matching ranges except for the outermost level. The (binary) function is applied as
(*f)(out_array1d, in_array1d)
f should not modify the index range of the output argument.

References stir::VectorWithOffset< Array< num_dimensions - 1, elemT > >::get_max_index(), stir::VectorWithOffset< Array< num_dimensions - 1, elemT > >::get_min_index(), and stir::Array< num_dimensions, elemT >::is_regular().

Referenced by stir::apply_array_functions_on_each_index().

◆ in_place_apply_array_functions_on_each_index()

template<int num_dim, typename elemT , typename FunctionObjectPtrIter >
void stir::in_place_apply_array_functions_on_each_index ( Array< num_dim, elemT > &  array,
FunctionObjectPtrIter  start,
FunctionObjectPtrIter  stop 
)
inline

Apply a sequence of 1d array-function objects on every dimension of the input array.

The sequence of function object pointers is specified by iterators. There must be num_dim function objects in the sequence, i.e. stop-start==num_dim.

The n-th function object (**(start+n)) is applied on the n-th index of the array. So, (*start) is applied using in_place_apply_array_function_on_1st_index(array, *start). Similarly, (*(start+1) is applied using in_place_apply_array_function_on_1st_index(array[i], *(start+1)) for every i. And so on.

Todo:
Add a specialisation such that this function would handle function objects and (smart) pointers to function objects. At the moment, it's only the latter.

References stir::VectorWithOffset< Array< num_dimensions - 1, elemT > >::begin(), stir::VectorWithOffset< Array< num_dimensions - 1, elemT > >::end(), and stir::in_place_apply_array_function_on_1st_index().

Referenced by stir::SeparableArrayFunctionObject< num_dimensions, elemT >::SeparableArrayFunctionObject().

◆ apply_array_functions_on_each_index() [1/2]

template<int num_dim, typename elemT , typename FunctionObjectPtrIter >
void stir::apply_array_functions_on_each_index ( Array< num_dim, elemT > &  out_array,
const Array< num_dim, elemT > &  in_array,
FunctionObjectPtrIter  start,
FunctionObjectPtrIter  stop 
)
inline

Apply a sequence of 1d array-function objects on every dimension of the input array, store in output array.

The sequence of function object pointers is specified by iterators. There must be num_dim function objects in the sequence, i.e. stop-start==num_dim.

The n-th function object (**(start+n)) is applied on the n-th indices of the arrays. So, (*start) is applied using

apply_array_function_on_1st_index(out_array, in_array, *start).

and so on.

Todo:
Add a specialisation such that this function would handle iterators of function objects and (smart) pointers to function objects. At the moment, it's only the latter.

References stir::apply_array_function_on_1st_index(), stir::VectorWithOffset< Array< num_dimensions - 1, elemT > >::get_max_index(), stir::VectorWithOffset< Array< num_dimensions - 1, elemT > >::get_min_index(), stir::Array< num_dimensions, elemT >::get_regular_range(), and stir::Array< num_dimensions, elemT >::is_regular().

Referenced by stir::SeparableArrayFunctionObject< num_dimensions, elemT >::SeparableArrayFunctionObject().

◆ apply_array_functions_on_each_index() [2/2]

template<int num_dim, typename elemT >
void stir::apply_array_functions_on_each_index ( Array< num_dim, elemT > &  out_array,
const Array< num_dim, elemT > &  in_array,
ActualFunctionObjectPtrIter  start,
ActualFunctionObjectPtrIter  stop 
)
inline

Apply a sequence of 1d array-function objects of a specific type on every dimension of the input array, store in output array.

This function uses optimisations possible because ArrayFunctionObject gives information on sizes etc.

Todo:
Modify such that this function would handle function objects and (smart) pointers to ArrayFunctionObject objects. At the moment, it's only the latter.

◆ assign_to_subregion()

template<class elemT >
void stir::assign_to_subregion ( Array< 3, elemT > &  input_array,
const BasicCoordinate< 3, int > &  mask_location,
const BasicCoordinate< 3, int > &  half_size,
const elemT &  value 
)
inline

assign a value to a sub-region of an array

sets all values for indices between mask_location - half_size and mask_location + half_size to value, taking care of staying inside the index-range of the array.

References stir::VectorWithOffset< T >::get_max_index(), and stir::VectorWithOffset< T >::get_min_index().

◆ find_unweighted_centre_of_gravity_1d()

template<class T >
T stir::find_unweighted_centre_of_gravity_1d ( const VectorWithOffset< T > &  row)

Compute centre of gravity of a vector but without dividing by its sum.

The unweighted centre of gravity is computed as follows:

\[ C_k = \sum_{i} i A_{i} \]

Referenced by stir::find_unweighted_centre_of_gravity().

◆ find_unweighted_centre_of_gravity() [1/2]

template<int num_dimensions, class T >
BasicCoordinate< num_dimensions, T > stir::find_unweighted_centre_of_gravity ( const Array< num_dimensions, T > &  )

Compute centre of gravity of an Array but without dividing by its sum.

Each coordinate of the unweighted centre of gravity is computed as follows:

\[ C_k = \sum_{i_1...i_n} i_k A_{i_1...i_n} \]

References stir::VectorWithOffset< Array< num_dimensions - 1, elemT > >::size().

Referenced by stir::find_centre_of_gravity().

◆ find_unweighted_centre_of_gravity() [2/2]

template<class T >
T stir::find_unweighted_centre_of_gravity ( const Array< 1, T > &  )

Compute centre of gravity of a 1D Array but without dividing by its sum.

Conceptually the same as the n-dimensional version, but returns a T, not a BasicCoordinate<1,T>.

References stir::find_unweighted_centre_of_gravity_1d().

◆ find_centre_of_gravity()

template<int num_dimensions, class T >
BasicCoordinate< num_dimensions, T > stir::find_centre_of_gravity ( const Array< num_dimensions, T > &  )

Compute centre of gravity of an Array.

Calls find_unweighted_centre_of_gravity and divides the result with the sum of all the elements in the array.

Warning
When the sum is 0, error() is called.
Todo:
better error handling

References stir::error(), stir::find_unweighted_centre_of_gravity(), stir::sum(), and stir::Array< num_dimensions, elemT >::sum().

◆ find_centre_of_gravity_in_mm_per_plane()

template<class T >
void stir::find_centre_of_gravity_in_mm_per_plane ( VectorWithOffset< CartesianCoordinate3D< float >> &  allCoG,
VectorWithOffset< T > &  weights,
const VoxelsOnCartesianGrid< T > &  image 
)

Computes centre of gravity for each plane.

The result is in mm in STIR physical coordinates, i.e. taking the origin into account.

The result can be used to find the central line of a (uniform) object, for instance a cylinder. The output of this function can by used by linear_regression().

The weight is currently simply the sum of the voxel values in that plane, thresholded to be at least 0. If the weight is 0, the x,y coordinates are simply set to 0.

◆ find_centre_of_gravity_in_mm()

template<class T >
CartesianCoordinate3D< float > stir::find_centre_of_gravity_in_mm ( const VoxelsOnCartesianGrid< T > &  image)

Computes centre of gravity of an image.

The result is in mm in STIR physical coordinates, i.e. taking the origin into account.

Referenced by stir::MatchTrackerAndScanner::run().

◆ find_scale_factor() [1/2]

template<int num_dimensions, class T1 , class T2 , class scaleT >
void stir::find_scale_factor ( scaleT &  scale_factor,
const Array< num_dimensions, T1 > &  data_in,
const NumericInfo< T2 >  info_for_out_type 
)
inline

A function that finds a scale factor to use when converting data to a new type.

The scale factor is such that (data_in / scale_factor) will fit in the maximum range for the output type.

When input and output types are identical, scale_factor is set to 1.

Parameters
scale_factora reference to a (float or double) variable which will be set to the scale factor such that (ignoring types)
data_in == data_out * scale_factor
If scale_factor is initialised to 0, the maximum range of T2 is used. If scale_factor != 0, find_scale_factor attempts to use the given scale_factor, unless the T2 range doesn't fit. In that case, the same scale_factor is used as in the 0 case.
data_insome Array object, elements are of some numeric type T1
info_for_out_typeT2 is the desired output type

Note that there is an effective threshold at 0 currently (i.e. negative numbers are ignored) when T2 is an unsigned type.

See also
convert_array

References stir::Array< num_dimensions, elemT >::begin_all(), and stir::Array< num_dimensions, elemT >::end_all().

Referenced by stir::write_data().

◆ convert_array() [1/2]

template<int num_dimensions, class T1 , class T2 , class scaleT >
Array< num_dimensions, T2 > stir::convert_array ( scaleT &  scale_factor,
const Array< num_dimensions, T1 > &  data_in,
const NumericInfo< T2 >  info2 
)
inline

A function that returns a new Array (of the same dimension) with elements of type T2.

Result is (approximately) data_in / scale_factor.

example
Array<2,float> data_out = convert_array(scale_factor, data_in, NumericInfo<float>())
Parameters
scale_factora reference to a (float or double) variable which will be set to the scale factor such that (ignoring types)
data_in == data_out * scale_factor
See also
find_scale_factor for more info on the determination of scale_factor.
Parameters
data_insome Array object, elements are of some numeric type T1
info2T2 is the desired output type
Returns
data_out : an Array object whose elements are of numeric type T2.

When the output type is integer, rounding is used.

Note that there is an effective threshold at 0 currently (i.e. negative numbers are cut out) when T2 is an unsigned type.

Referenced by stir::read_data(), and stir::convert_array_Tests::run_tests().

◆ convert_array() [2/2]

template<int num_dimensions, class T1 , class T2 , class scaleT >
void stir::convert_array ( Array< num_dimensions, T2 > &  data_out,
scaleT &  scale_factor,
const Array< num_dimensions, T1 > &  data_in 
)
inline

Converts the data_in Array to data_out (with elements of different types) such that data_in == data_out * scale_factor.

example
convert_array(data_out, scale_factor, data_in);
See also
convert_array(scale_factor, data_in, info2) for more info

References stir::Array< num_dimensions, elemT >::begin_all(), stir::convert_range(), and stir::Array< num_dimensions, elemT >::end_all().

◆ find_scale_factor() [2/2]

template<class InputIteratorT , class T2 , class scaleT >
void stir::find_scale_factor ( scaleT &  scale_factor,
const InputIteratorT &  begin,
const InputIteratorT &  end,
const NumericInfo< T2 >  info_for_out_type 
)
inline

A function that finds a scale factor to use when converting data to a new type.

This function works with input data given as an iterator range.

See also
find_scale_factor(scale_factor,data_in,info_for_out_type)

◆ convert_range()

template<class OutputIteratorT , class InputIteratorT , class scaleT >
void stir::convert_range ( const OutputIteratorT &  out_begin,
scaleT &  scale_factor,
const InputIteratorT &  in_begin,
const InputIteratorT &  in_end 
)
inline

Converts the data in the input range to the output range (with elements of different types) such that data_in == data_out * scale_factor.

Note order of arguments. Output-range occurs first (as standard in STIR).

example
convert_range(data_out.begin_all(), scale_factor,
data_in.begin_all(), data_in.end_all());
See also
convert_array(scale_factor, data_in, info2) for more info

Referenced by stir::convert_array(), and stir::convert_array_Tests::run_tests().