GooseEYE 0.9.1
Loading...
Searching...
No Matches
GooseEYE Namespace Reference

Toolbox to compute statistics. More...

Namespaces

namespace  array_type
 Container type.
 
namespace  kernel
 Collect kernels.
 

Classes

class  ClusterLabeller
 (Incrementally) Label clusters (0 as background, 1..n as labels). More...
 
class  Ensemble
 Compute ensemble averaged statistics, by repetitively calling the member-function of a certain statistical measure with different data. More...
 

Enumerations

enum class  path_mode { Bresenham , actual , full }
 Different methods to compute a pixel-path. More...
 

Functions

array_type::tensor< int, 2 > path (const array_type::tensor< int, 1 > &x0, const array_type::tensor< int, 1 > &x1, path_mode mode=path_mode::Bresenham)
 Compute a path between two pixels.
 
array_type::array< int > dummy_circles (const std::vector< size_t > &shape, const array_type::tensor< int, 1 > &row, const array_type::tensor< int, 1 > &col, const array_type::tensor< int, 1 > &r, bool periodic=true)
 Dummy image with circles.
 
array_type::array< int > dummy_circles (const std::vector< size_t > &shape, bool periodic=true, uint64_t seed=0)
 Dummy image with circles.
 
template<class T , class S , std::enable_if_t< std::is_integral< typename T::value_type >::value &&std::is_integral< typename S::value_type >::value, int > = 0>
dilate (const T &f, const S &kernel, const array_type::tensor< size_t, 1 > &iterations, bool periodic=true)
 Dilate image.
 
template<class T , std::enable_if_t< std::is_integral< typename T::value_type >::value, int > = 0>
dilate (const T &f, const array_type::tensor< size_t, 1 > &iterations, bool periodic=true)
 Dilate image.
 
template<class T , class S , std::enable_if_t< std::is_integral< typename T::value_type >::value &&std::is_integral< typename S::value_type >::value, int > = 0>
dilate (const T &f, const S &kernel, size_t iterations=1, bool periodic=true)
 Dilate image.
 
template<class T , std::enable_if_t< std::is_integral< typename T::value_type >::value, int > = 0>
dilate (const T &f, size_t iterations=1, bool periodic=true)
 Dilate image.
 
template<class T >
array_type::tensor< typename T::value_type, 2 > labels_map (const T &a, const T &b)
 Get a map to relabel from a to b.
 
template<class L , class A >
L labels_rename (const L &labels, const A &rename)
 Rename labels.
 
template<class T >
labels_prune (const T &labels)
 Prune labels: renumber labels to lowest possible label starting from 1.
 
template<class L , class A >
L labels_reorder (const L &labels, const A &order)
 Reorder labels.
 
template<class T >
array_type::tensor< typename T::value_type, 2 > labels_sizes (const T &labels)
 Size per label.
 
template<class T , class N >
array_type::tensor< typename T::value_type, 1 > labels_sizes (const T &labels, const N &names)
 Size per label.
 
template<class T >
array_type::array< int > clusters (const T &f, bool periodic=true)
 Compute clusters.
 
array_type::tensor< double, 1 > center (const array_type::tensor< double, 1 > &shape, const array_type::tensor< double, 2 > &positions, bool periodic=true)
 Return the geometric center of a list of positions.
 
array_type::tensor< double, 1 > center_of_mass (const array_type::tensor< double, 1 > &shape, const array_type::tensor< double, 2 > &positions, const array_type::tensor< double, 1 > &weights, bool periodic=true)
 Return the geometric center of a list of positions.
 
template<class T , class N >
array_type::tensor< double, 2 > labels_centers (const T &labels, const N &names, bool periodic=true)
 Get the position of the center of each label.
 
template<class T , class W , class N >
array_type::tensor< double, 2 > labels_centers_of_mass (const T &labels, const W &weights, const N &names, bool periodic=true)
 Get the position of the center of each label.
 
auto distance (const std::vector< size_t > &roi)
 Get the relative distance of each pixel in the 'region-of-interest' to its center.
 
auto distance (const std::vector< size_t > &roi, size_t axis)
 Get the relative distance of each pixel in the 'region-of-interest' to its center.
 
auto distance (const std::vector< size_t > &roi, const std::vector< double > &h)
 Get the relative distance of each pixel in the 'region-of-interest' to its center.
 
auto distance (const std::vector< size_t > &roi, const std::vector< double > &h, size_t axis)
 Get the relative distance of each pixel in the 'region-of-interest' to its center.
 
template<class T >
auto S2 (const std::vector< size_t > &roi, const T &f, const T &g, bool periodic=true)
 2-point correlation: P(f(i) * g(i + di)).
 
template<class T , class M >
auto S2 (const std::vector< size_t > &roi, const T &f, const T &g, const M &fmask, const M &gmask, bool periodic=true)
 2-point correlation: P(f(i) * g(i + di)).
 
template<class T >
auto C2 (const std::vector< size_t > &roi, const T &f, const T &g, bool periodic=true)
 2-point cluster function: P(f(i) == g(i + di)).
 
template<class T , class M >
auto C2 (const std::vector< size_t > &roi, const T &f, const T &g, const M &fmask, const M &gmask, bool periodic=true)
 2-point cluster function: P(f(i) == g(i + di)).
 
template<class T >
auto W2 (const std::vector< size_t > &roi, const T &w, const T &f, bool periodic=true)
 Weighted 2-point correlation.
 
template<class T , class M >
auto W2 (const std::vector< size_t > &roi, const T &w, const T &f, const M &fmask, bool periodic=true)
 Weighted 2-point correlation.
 
template<class C , class T >
auto W2c (const std::vector< size_t > &roi, const C &clusters, const C &centers, const T &f, path_mode mode=path_mode::Bresenham, bool periodic=true)
 Collapsed weighted 2-point correlation.
 
template<class C , class T , class M >
auto W2c (const std::vector< size_t > &roi, const C &clusters, const C &centers, const T &f, const M &fmask, path_mode mode=path_mode::Bresenham, bool periodic=true)
 Collapsed weighted 2-point correlation.
 
template<class T >
auto heightheight (const std::vector< size_t > &roi, const T &f, bool periodic=true)
 Height-height correlation.
 
template<class T , class M >
auto heightheight (const std::vector< size_t > &roi, const T &f, const M &fmask, bool periodic=true)
 Height-height correlation.
 
template<class T >
auto L (const std::vector< size_t > &roi, const T &f, bool periodic=true, path_mode mode=path_mode::Bresenham)
 Lineal-path function.
 
std::string version ()
 Return version string, e.g.
 

Detailed Description

Toolbox to compute statistics.

Enumeration Type Documentation

◆ path_mode

enum class GooseEYE::path_mode
strong

Different methods to compute a pixel-path.

Enumerator
Bresenham 

Bresenham algorithm.

actual 

The actual path.

full 

Similar to actual selecting every voxel that is crossed.

Definition at line 93 of file GooseEYE.h.

Function Documentation

◆ C2() [1/2]

template<class T >
auto GooseEYE::C2 ( const std::vector< size_t > & roi,
const T & f,
const T & g,
bool periodic = true )
inline

2-point cluster function: P(f(i) == g(i + di)).

Parameters
roiRegion-of-interest.
fThe image.
gThe comparison image.
periodicSwitch to assume image periodic.

Definition at line 75 of file GooseEYE.hpp.

◆ C2() [2/2]

template<class T , class M >
auto GooseEYE::C2 ( const std::vector< size_t > & roi,
const T & f,
const T & g,
const M & fmask,
const M & gmask,
bool periodic = true )
inline

2-point cluster function: P(f(i) == g(i + di)).

Parameters
roiRegion-of-interest.
fThe image.
gThe comparison image.
fmaskMask certain pixels of f (binary, 1: masked, 0: not masked).
gmaskMask certain pixels of g (binary, 1: masked, 0: not masked).
periodicSwitch to assume image periodic.

Definition at line 84 of file GooseEYE.hpp.

◆ center()

array_type::tensor< double, 1 > GooseEYE::center ( const array_type::tensor< double, 1 > & shape,
const array_type::tensor< double, 2 > & positions,
bool periodic = true )
inline

Return the geometric center of a list of positions.

Note
The positions are organised as one column per dimension. For example, in 2d, the positions are organised as positions = np.hstack((rows.reshape(-1, 1), cols.reshape(-1, 1))). You can also use positions = np.argwhere(condition). This means that the following two calls are equivalent:
>>> centers(shape=labels.shape, positions=np.argwhere(labels == 1), periodic=True)
>>> labels_centers(labels=labels, names=[1], periodic=True)[0, :]

For periodic algorithm, see: https://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions

Parameters
shapeShape of the box to which the coordinates below (needed to apply periodicity).
positionsList of positions (in array coordinates, e.g. [rows, columns]).
periodicSwitch to assume array periodic.
Returns
Coordinates of the center (in array coordinates, e.g. [center_row, center_col]).

Definition at line 1246 of file GooseEYE.h.

◆ center_of_mass()

array_type::tensor< double, 1 > GooseEYE::center_of_mass ( const array_type::tensor< double, 1 > & shape,
const array_type::tensor< double, 2 > & positions,
const array_type::tensor< double, 1 > & weights,
bool periodic = true )
inline

Return the geometric center of a list of positions.

Note
The positions are organised as one column per dimension. For example, in 2d, the positions are organised as positions = np.hstack((rows.reshape(-1, 1), cols.reshape(-1, 1))). You can also use positions = np.argwhere(condition). This means that the following two calls are equivalent:
>>> centers(shape=labels.shape, positions=np.argwhere(labels == 1), periodic=True)
>>> labels_centers(labels=labels, names=[1], periodic=True)[0, :]

For periodic algorithm, see: https://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions

Parameters
shapeShape of the box to which the coordinates below (needed to apply periodicity).
positionsList of positions (in array coordinates, e.g. [rows, columns]).
periodicSwitch to assume array periodic.
Returns
Coordinates of the center (in array coordinates, e.g. [center_row, center_col]).
Parameters
weightsWeight for each position.

Definition at line 1274 of file GooseEYE.h.

◆ clusters()

template<class T >
array_type::array< int > GooseEYE::clusters ( const T & f,
bool periodic = true )
inline

Compute clusters.

Parameters
fImage.
periodicInterpret image as periodic.
Returns
'Image' with labels (1..n) for labels, 0 for background.

Definition at line 1198 of file GooseEYE.h.

◆ dilate() [1/4]

template<class T , std::enable_if_t< std::is_integral< typename T::value_type >::value, int > = 0>
T GooseEYE::dilate ( const T & f,
const array_type::tensor< size_t, 1 > & iterations,
bool periodic = true )
inline

Dilate image.

Select "kernel::nearest" as kernel. See above for parameters.

Definition at line 388 of file GooseEYE.h.

◆ dilate() [2/4]

template<class T , class S , std::enable_if_t< std::is_integral< typename T::value_type >::value &&std::is_integral< typename S::value_type >::value, int > = 0>
T GooseEYE::dilate ( const T & f,
const S & kernel,
const array_type::tensor< size_t, 1 > & iterations,
bool periodic = true )
inline

Dilate image.

The input image can be binary (1), or have integer labels (>=1). In each case the background are 0.

Parameters
fThe image (integer).
kernelThe kernel with which to dilate (binary).
iterationsNumber of iterations per label.
periodicSwitch to assume image periodic.
Returns
The dilated image.

Definition at line 299 of file GooseEYE.h.

◆ dilate() [3/4]

template<class T , class S , std::enable_if_t< std::is_integral< typename T::value_type >::value &&std::is_integral< typename S::value_type >::value, int > = 0>
T GooseEYE::dilate ( const T & f,
const S & kernel,
size_t iterations = 1,
bool periodic = true )
inline

Dilate image.

Fixed number of iterations for all labels. See above for parameters.

Definition at line 404 of file GooseEYE.h.

◆ dilate() [4/4]

template<class T , std::enable_if_t< std::is_integral< typename T::value_type >::value, int > = 0>
T GooseEYE::dilate ( const T & f,
size_t iterations = 1,
bool periodic = true )
inline

Dilate image.

Fixed number of iterations for all labels. Select "kernel::nearest" as kernel. See above for parameters.

Definition at line 415 of file GooseEYE.h.

◆ distance() [1/4]

auto GooseEYE::distance ( const std::vector< size_t > & roi)
inline

Get the relative distance of each pixel in the 'region-of-interest' to its center.

Parameters
roiRegion-of-interest.
Returns
The distances along the 'region-of-interest' set at construction.

Definition at line 28 of file GooseEYE.hpp.

◆ distance() [2/4]

auto GooseEYE::distance ( const std::vector< size_t > & roi,
const std::vector< double > & h )
inline

Get the relative distance of each pixel in the 'region-of-interest' to its center.

Parameters
roiRegion-of-interest.
hThe physical dimensions of one pixel (in each direction).
Returns
The distances along the 'region-of-interest' set at construction.

Definition at line 40 of file GooseEYE.hpp.

◆ distance() [3/4]

auto GooseEYE::distance ( const std::vector< size_t > & roi,
const std::vector< double > & h,
size_t axis )
inline

Get the relative distance of each pixel in the 'region-of-interest' to its center.

Parameters
roiRegion-of-interest.
hThe physical dimensions of one pixel (in each direction).
axisSelect axis.
Returns
The distances along the 'region-of-interest' set at construction.

Definition at line 46 of file GooseEYE.hpp.

◆ distance() [4/4]

auto GooseEYE::distance ( const std::vector< size_t > & roi,
size_t axis )
inline

Get the relative distance of each pixel in the 'region-of-interest' to its center.

Parameters
roiRegion-of-interest.
axisSelect axis.
Returns
The distances along the 'region-of-interest' set at construction.

Definition at line 34 of file GooseEYE.hpp.

◆ dummy_circles() [1/2]

array_type::array< int > GooseEYE::dummy_circles ( const std::vector< size_t > & shape,
bool periodic = true,
uint64_t seed = 0 )
inline

Dummy image with circles.

The positions and radii of the circles are randomly generated.

Parameters
shapeShape of the output image.
periodicSwitch to assume image periodic.
seedSeed for the random number generator.
Returns
The dummy image.

Definition at line 172 of file GooseEYE.h.

◆ dummy_circles() [2/2]

array_type::array< int > GooseEYE::dummy_circles ( const std::vector< size_t > & shape,
const array_type::tensor< int, 1 > & row,
const array_type::tensor< int, 1 > & col,
const array_type::tensor< int, 1 > & r,
bool periodic = true )
inline

Dummy image with circles.

Parameters
shapeShape of the output image.
rowThe x-position of each circle.
colThe y-position of each circle.
rThe radius of each circle.
periodicSwitch to assume image periodic.
Returns
The dummy image.

Definition at line 120 of file GooseEYE.h.

◆ heightheight() [1/2]

template<class T >
auto GooseEYE::heightheight ( const std::vector< size_t > & roi,
const T & f,
bool periodic = true )
inline

Height-height correlation.

Parameters
roiRegion-of-interest.
fThe image.
periodicSwitch to assume image periodic.

Definition at line 143 of file GooseEYE.hpp.

◆ heightheight() [2/2]

template<class T , class M >
auto GooseEYE::heightheight ( const std::vector< size_t > & roi,
const T & f,
const M & fmask,
bool periodic = true )
inline

Height-height correlation.

Parameters
roiRegion-of-interest.
fThe image.
fmaskMask certain pixels of f (binary, 1: masked, 0: not masked).
periodicSwitch to assume image periodic.

Definition at line 151 of file GooseEYE.hpp.

◆ L()

template<class T >
auto GooseEYE::L ( const std::vector< size_t > & roi,
const T & f,
bool periodic = true,
path_mode mode = path_mode::Bresenham )
inline

Lineal-path function.

Parameters
roiRegion-of-interest.
fThe image.
periodicSwitch to assume image periodic.
modeMethod to use (see path_mode()).

Definition at line 159 of file GooseEYE.hpp.

◆ labels_centers()

template<class T , class N >
array_type::tensor< double, 2 > GooseEYE::labels_centers ( const T & labels,
const N & names,
bool periodic = true )
inline

Get the position of the center of each label.

Note
To compute the center of a single label, you can also use GooseEYE::center().
Parameters
labelsAn image with labels.
namesList of labels to compute the center for.
periodicSwitch to assume image periodic.
Returns
Coordinates of the center (in array coordinates), in order of the unique (sorted) labels.

Definition at line 1340 of file GooseEYE.h.

◆ labels_centers_of_mass()

template<class T , class W , class N >
array_type::tensor< double, 2 > GooseEYE::labels_centers_of_mass ( const T & labels,
const W & weights,
const N & names,
bool periodic = true )
inline

Get the position of the center of each label.

Note
To compute the center of a single label, you can also use GooseEYE::center().
Parameters
labelsAn image with labels.
namesList of labels to compute the center for.
periodicSwitch to assume image periodic.
Returns
Coordinates of the center (in array coordinates), in order of the unique (sorted) labels.
Parameters
weightsWeight for each pixel.

Definition at line 1368 of file GooseEYE.h.

◆ labels_map()

template<class T >
array_type::tensor< typename T::value_type, 2 > GooseEYE::labels_map ( const T & a,
const T & b )
inline

Get a map to relabel from a to b.

Parameters
aImage with labels.
bImage with labels.
Returns
Array with each row the pair (old_label, new_label).

Definition at line 428 of file GooseEYE.h.

◆ labels_prune()

template<class T >
T GooseEYE::labels_prune ( const T & labels)
inline

Prune labels: renumber labels to lowest possible label starting from 1.

Note that the background 0 is always kept 0.

Parameters
labelsImage with labels.
Returns
Image with reordered labels.

Definition at line 490 of file GooseEYE.h.

◆ labels_rename()

template<class L , class A >
L GooseEYE::labels_rename ( const L & labels,
const A & rename )
inline

Rename labels.

Parameters
labelsImage with labels.
renameArray with each row the pair (old_label, new_label).
Returns
Image with reordered labels.

Definition at line 457 of file GooseEYE.h.

◆ labels_reorder()

template<class L , class A >
L GooseEYE::labels_reorder ( const L & labels,
const A & order )
inline

Reorder labels.

Parameters
labelsImage with labels.
orderList of new order of labels (unique(labels) in desired order).
Returns
Image with reordered labels.

Definition at line 536 of file GooseEYE.h.

◆ labels_sizes() [1/2]

template<class T >
array_type::tensor< typename T::value_type, 2 > GooseEYE::labels_sizes ( const T & labels)
inline

Size per label.

Parameters
labelsImage with labels.
Returns
List of size n + 1 with the size per label.

Definition at line 588 of file GooseEYE.h.

◆ labels_sizes() [2/2]

template<class T , class N >
array_type::tensor< typename T::value_type, 1 > GooseEYE::labels_sizes ( const T & labels,
const N & names )
inline

Size per label.

Parameters
labelsImage with labels.
namesList of 'names' to extract.
Returns
Size of each label in names.

Definition at line 612 of file GooseEYE.h.

◆ path()

array_type::tensor< int, 2 > GooseEYE::path ( const array_type::tensor< int, 1 > & x0,
const array_type::tensor< int, 1 > & x1,
path_mode mode = path_mode::Bresenham )
inline

Compute a path between two pixels.

Parameters
x0Pixel coordinate (e.g. {0, 0}).
x1Pixel coordinate (e.g. {10, 5}).
modeMethod to use (see "path_mode").
Returns
The path: the coordinate of one pixel per row.

Definition at line 15 of file GooseEYE.hpp.

◆ S2() [1/2]

template<class T >
auto GooseEYE::S2 ( const std::vector< size_t > & roi,
const T & f,
const T & g,
bool periodic = true )
inline

2-point correlation: P(f(i) * g(i + di)).

Parameters
roiRegion-of-interest.
fThe image.
gThe comparison image.
periodicSwitch to assume image periodic.

Definition at line 53 of file GooseEYE.hpp.

◆ S2() [2/2]

template<class T , class M >
auto GooseEYE::S2 ( const std::vector< size_t > & roi,
const T & f,
const T & g,
const M & fmask,
const M & gmask,
bool periodic = true )
inline

2-point correlation: P(f(i) * g(i + di)).

Parameters
roiRegion-of-interest.
fThe image.
gThe comparison image.
fmaskMask certain pixels of f (binary, 1: masked, 0: not masked).
gmaskMask certain pixels of g (binary, 1: masked, 0: not masked).
periodicSwitch to assume image periodic.

Definition at line 62 of file GooseEYE.hpp.

◆ version()

std::string GooseEYE::version ( )
inline

Return version string, e.g.

"0.8.0"

Returns
String.

Definition at line 25 of file version.hpp.

◆ W2() [1/2]

template<class T >
auto GooseEYE::W2 ( const std::vector< size_t > & roi,
const T & w,
const T & f,
bool periodic = true )
inline

Weighted 2-point correlation.

Parameters
roiRegion-of-interest.
wWeights.
fThe image.
periodicSwitch to assume image periodic.

Definition at line 97 of file GooseEYE.hpp.

◆ W2() [2/2]

template<class T , class M >
auto GooseEYE::W2 ( const std::vector< size_t > & roi,
const T & w,
const T & f,
const M & fmask,
bool periodic = true )
inline

Weighted 2-point correlation.

Parameters
roiRegion-of-interest.
wWeights.
fThe image.
fmaskMask certain pixels of f (binary, 1: masked, 0: not masked).
periodicSwitch to assume image periodic.

Definition at line 106 of file GooseEYE.hpp.

◆ W2c() [1/2]

template<class C , class T , class M >
auto GooseEYE::W2c ( const std::vector< size_t > & roi,
const C & clusters,
const C & centers,
const T & f,
const M & fmask,
path_mode mode = path_mode::Bresenham,
bool periodic = true )
inline

Collapsed weighted 2-point correlation.

Parameters
roiRegion-of-interest.
clustersThe clusters.
centersThe cluster-centers: label only at the center.
fThe image.
fmaskMask certain pixels of f (binary, 1: masked, 0: not masked).
modeMethod to use (see path_mode()).
periodicSwitch to assume image periodic.

Definition at line 129 of file GooseEYE.hpp.

◆ W2c() [2/2]

template<class C , class T >
auto GooseEYE::W2c ( const std::vector< size_t > & roi,
const C & clusters,
const C & centers,
const T & f,
path_mode mode = path_mode::Bresenham,
bool periodic = true )
inline

Collapsed weighted 2-point correlation.

Parameters
roiRegion-of-interest.
clustersThe clusters.
centersThe cluster-centers: label only at the center.
fThe image.
modeMethod to use (see path_mode()).
periodicSwitch to assume image periodic.

Definition at line 115 of file GooseEYE.hpp.