lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
localextrema Namespace Reference

Local-extremum search functions for 1-d and 2-d arrays (maps of local minima and maxima, lists of extremum indexes) used by the peak finders. More...

Typedefs

typedef types::mask_t mask_t
 LocalExtrema - methods for 2-d image processing algorithms.
 
typedef types::extrim_t extrim_t
 Alias for types::extrim_t (uint16_t).
 
typedef types::TwoIndexes TwoIndexes
 Alias for types::TwoIndexes.
 

Functions

AllocArray1D< TwoIndexes > evaluateDiagIndexes_drp (const size_t &rank, Allocator *allocator)
 Return the (i, j) offsets with -rank <= i, j <= rank and both nonzero (the square around a pixel without its central row and column), in an AllocArray1D allocated from allocator.
 
void printMatrixOfDiagIndexes (const size_t &rank)
 Print to stdout a (2*rank+1) x (2*rank+1) matrix of the offsets used by evaluateDiagIndexes(): 1 for used, 0 for the central row and column, and + at the center.
 
void printVectorOfDiagIndexes (const size_t &rank)
 Print the size and the (i, j) pairs of evaluateDiagIndexes(rank) to stdout, ten pairs per line.
 
size_t numberOfExtrema (const extrim_t *map, const size_t &rows, const size_t &cols, const extrim_t &vsel=7)
 Return how many of the rows*cols entries of map equal vsel.
 
std::vector< TwoIndexes > evaluateDiagIndexes (const size_t &rank)
 Return the (i, j) offsets with -rank <= i, j <= rank and both nonzero, as a std::vector.
 
std::vector< TwoIndexes > vectorOfExtremeIndexes (const extrim_t *map, const size_t &rows, const size_t &cols, const extrim_t &vsel=7, const size_t &maxlen=0)
 Return the (row, col) indexes of all entries of map equal to vsel, in row-major order.
 
template<typename T >
size_t localMinima1d (const T *data, const mask_t *mask, const size_t &cols, const size_t &stride=1, const size_t &rank=5, extrim_t *local_minima=0)
 returns number of found minima and array local_minima of local minimums of requested rank, where rank defins a square region [cols-rank, cols+rank].
 
template<typename T >
size_t localMaxima1d (const T *data, const mask_t *mask, const size_t &cols, const size_t &stride=1, const size_t &rank=5, extrim_t *local_maxima=0)
 returns number of found maxima and array local_maxima of local maximums of requested rank, where rank defins a region [cols-rank, cols+rank].
 
template<typename T >
size_t mapOfLocalMinimums_drp (const T *data, const mask_t *mask, const size_t &rows, const size_t &cols, const size_t &rank, extrim_t *local_minima, Allocator *allocator)
 returns map of local minimums of requested rank, where rank defins a square region around central pixel [rowc-rank, rowc+rank], [colc-rank, colc+rank].
 
template<typename T >
size_t mapOfLocalMaximums_drp (const T *data, const mask_t *mask, const size_t &rows, const size_t &cols, const size_t &rank, extrim_t *local_maxima, Allocator *allocator)
 returns map of local maximums of requested rank, where rank defins a square region around central pixel [rowc-rank, rowc+rank], [colc-rank, colc+rank].
 
template<typename T >
size_t mapOfLocalMaximumsRank1Cross (const T *data, const mask_t *mask, const size_t &rows, const size_t &cols, extrim_t *local_maxima)
 returns map of local maximums of runk=1 cross(+) region (very special case for Chuck's algorithm).
 
template<typename T >
size_t mapOfThresholdMaximums (const T *data, const mask_t *mask, const size_t &rows, const size_t &cols, const size_t &rank, const double &thr_low, const T &thr_high, extrim_t *thr_maxima)
 returns map of local maximums for 2-threshold algorithm.
 
template<typename T >
size_t mapOfLocalMinimums (const T *data, const mask_t *mask, const size_t &rows, const size_t &cols, const size_t &rank, extrim_t *local_minima)
 returns map of local minimums of requested rank, where rank defins a square region around central pixel [rowc-rank, rowc+rank], [colc-rank, colc+rank].
 
template<typename T >
size_t mapOfLocalMaximums (const T *data, const mask_t *mask, const size_t &rows, const size_t &cols, const size_t &rank, extrim_t *local_maxima)
 returns map of local maximums of requested rank, where rank defins a square region around central pixel [rowc-rank, rowc+rank], [colc-rank, colc+rank].
 

Detailed Description

Local-extremum search functions for 1-d and 2-d arrays (maps of local minima and maxima, lists of extremum indexes) used by the peak finders.

Typedef Documentation

◆ extrim_t

◆ mask_t

LocalExtrema - methods for 2-d image processing algorithms.

This software was developed for the LCLS project.
If you use all or part of it, please give an appropriate acknowledgment.

Author
Mikhail Dubrovin
See also
ImgAlgos.ImgImgProc

Interface Description
  • Includes and typedefs
    #include <cstddef> // for size_t
    #include "psalgos/LocalExtrema.h"
    #include "psalgos/Types.h"
    Non-owning view of an array of T: a data pointer, a pointer to a shape array and a rank.
    Definition Array.hh:27
    types::extrim_t extrim_t
    Alias for types::extrim_t (uint16_t).
    Definition LocalExtrema.hh:100
    types::mask_t mask_t
    LocalExtrema - methods for 2-d image processing algorithms.
    Definition LocalExtrema.hh:98
  • Define input parameters
    const T *data = ...
    const mask_t *mask = ...
    const size_t rows = 1000;
    const size_t cols = 1000;
    const size_t rank = 5;
    const T thr_low = 30;
    const T thr_high = 60;
    extrim_t *local_maxima = new extrim_t[rows*cols];
  • Call methods
    size_t n = localMinima1d(data, mask, cols, stride, rank, local_minima);
    size_t n = localMaxima1d(data, mask, cols, stride, rank, local_maxima);
    size_t n = mapOfLocalMinimums(data, mask, rows, cols, rank, arr2d);
    size_t n = mapOfLocalMaximums(data, mask, rows, cols, rank, arr2d);
    size_t n = mapOfLocalMaximumsRank1Cross(data, mask, rows, cols, arr2d);
    size_t n = mapOfThresholdMaximums(data ,mask, rows, cols, rank, thr_low, thr_high, local_maxima)
    std::vector<TwoIndexes> v = evaluateDiagIndexes(const size_t& rank);
    const extrim_t vsel=7;
    const size_t maxlen=1000;
    std::vector<TwoIndexes> v = vectorOfExtremeIndexes(map, rows, cols, vsel, maxlen);
    size_t n = numberOfExtrema(local_maxima, rows, cols, vsel);
    size_t numberOfExtrema(const extrim_t *map, const size_t &rows, const size_t &cols, const extrim_t &vsel=7)
    Return how many of the rows*cols entries of map equal vsel.
    void printVectorOfDiagIndexes(const size_t &rank)
    Print the size and the (i, j) pairs of evaluateDiagIndexes(rank) to stdout, ten pairs per line.
    size_t mapOfThresholdMaximums(const T *data, const mask_t *mask, const size_t &rows, const size_t &cols, const size_t &rank, const double &thr_low, const T &thr_high, extrim_t *thr_maxima)
    returns map of local maximums for 2-threshold algorithm.
    Definition LocalExtrema.hh:798
    void printMatrixOfDiagIndexes(const size_t &rank)
    Print to stdout a (2*rank+1) x (2*rank+1) matrix of the offsets used by evaluateDiagIndexes(): 1 for ...
    std::vector< TwoIndexes > evaluateDiagIndexes(const size_t &rank)
    Return the (i, j) offsets with -rank <= i, j <= rank and both nonzero, as a std::vector.
    size_t mapOfLocalMaximums(const T *data, const mask_t *mask, const size_t &rows, const size_t &cols, const size_t &rank, extrim_t *local_maxima)
    returns map of local maximums of requested rank, where rank defins a square region around central pix...
    Definition LocalExtrema.hh:1057
    size_t localMinima1d(const T *data, const mask_t *mask, const size_t &cols, const size_t &stride=1, const size_t &rank=5, extrim_t *local_minima=0)
    returns number of found minima and array local_minima of local minimums of requested rank,...
    Definition LocalExtrema.hh:137
    size_t localMaxima1d(const T *data, const mask_t *mask, const size_t &cols, const size_t &stride=1, const size_t &rank=5, extrim_t *local_maxima=0)
    returns number of found maxima and array local_maxima of local maximums of requested rank,...
    Definition LocalExtrema.hh:249
    size_t mapOfLocalMinimums(const T *data, const mask_t *mask, const size_t &rows, const size_t &cols, const size_t &rank, extrim_t *local_minima)
    returns map of local minimums of requested rank, where rank defins a square region around central pix...
    Definition LocalExtrema.hh:889
    size_t mapOfLocalMaximumsRank1Cross(const T *data, const mask_t *mask, const size_t &rows, const size_t &cols, extrim_t *local_maxima)
    returns map of local maximums of runk=1 cross(+) region (very special case for Chuck's algorithm).
    Definition LocalExtrema.hh:689
    std::vector< TwoIndexes > vectorOfExtremeIndexes(const extrim_t *map, const size_t &rows, const size_t &cols, const extrim_t &vsel=7, const size_t &maxlen=0)
    Return the (row, col) indexes of all entries of map equal to vsel, in row-major order.

◆ TwoIndexes

Function Documentation

◆ evaluateDiagIndexes()

std::vector< TwoIndexes > localextrema::evaluateDiagIndexes ( const size_t &  rank)

Return the (i, j) offsets with -rank <= i, j <= rank and both nonzero, as a std::vector.

◆ evaluateDiagIndexes_drp()

AllocArray1D< TwoIndexes > localextrema::evaluateDiagIndexes_drp ( const size_t &  rank,
Allocator *  allocator 
)

Return the (i, j) offsets with -rank <= i, j <= rank and both nonzero (the square around a pixel without its central row and column), in an AllocArray1D allocated from allocator.

◆ localMaxima1d()

template<typename T >
size_t localextrema::localMaxima1d ( const T *  data,
const mask_t *  mask,
const size_t &  cols,
const size_t &  stride = 1,
const size_t &  rank = 5,
extrim_t *  local_maxima = 0 
)

returns number of found maxima and array local_maxima of local maximums of requested rank, where rank defins a region [cols-rank, cols+rank].

Assumes that cols > 2*rank...

1-d array of local maxumum of (uint16) values of data shape, with 0/+1/+2 for bad/non-maxumum/maximum in rank region.

Parameters
[in]data- pointer to data array
[in]mask- pointer to mask array; mask marks bad/good (0/1) pixels
[in]cols- number of columns in 1d array
[in]stride- index increment between neighbour elements. Makes sence for n-d arrays
[in]rank- radius of the square region in which central pixel has a maximal value
[out]local_maxima- pointer to the array local_maxima

◆ localMinima1d()

template<typename T >
size_t localextrema::localMinima1d ( const T *  data,
const mask_t *  mask,
const size_t &  cols,
const size_t &  stride = 1,
const size_t &  rank = 5,
extrim_t *  local_minima = 0 
)

returns number of found minima and array local_minima of local minimums of requested rank, where rank defins a square region [cols-rank, cols+rank].

Assumes that cols > 2*rank...

1-d array of local minumum of (uint16) values of data shape, with 0/+1/+2 for bad/non-minumum/minimum in rank region.

Parameters
[in]data- pointer to data array
[in]mask- pointer to mask array; mask marks bad/good (0/1) pixels
[in]cols- number of columns in 1d array
[in]stride- index increment between neighbour elements. Makes sence for n-d arrays
[in]rank- radius of the square region in which central pixel has a maximal value
[out]local_minima- pointer to the array local_minima

◆ mapOfLocalMaximums()

template<typename T >
size_t localextrema::mapOfLocalMaximums ( const T *  data,
const mask_t *  mask,
const size_t &  rows,
const size_t &  cols,
const size_t &  rank,
extrim_t *  local_maxima 
)

returns map of local maximums of requested rank, where rank defins a square region around central pixel [rowc-rank, rowc+rank], [colc-rank, colc+rank].

Map of local maximum is a 2-d array of (uint16) values of data shape, with 0/+1/+2/+4 for non-maximum / maximum in column / maximum in row / minimum in square of radius rank.

Parameters
[in]data- pointer to data array
[in]mask- pointer to mask array; mask marks bad/good (0/1) pixels
[in]rows- number of rows in all 2-d arrays
[in]cols- number of columns in all 2-d arrays
[in]rank- radius of the square region in which central pixel has a maximal value
[out]local_maxima- pointer to map of local maximums

◆ mapOfLocalMaximums_drp()

template<typename T >
size_t localextrema::mapOfLocalMaximums_drp ( const T *  data,
const mask_t *  mask,
const size_t &  rows,
const size_t &  cols,
const size_t &  rank,
extrim_t *  local_maxima,
Allocator *  allocator 
)

returns map of local maximums of requested rank, where rank defins a square region around central pixel [rowc-rank, rowc+rank], [colc-rank, colc+rank].

Map of local maximum is a 2-d array of (uint16) values of data shape, with 0/+1/+2/+4 for non-maximum / maximum in column / maximum in row / minimum in square of radius rank.

Parameters
[in]data- pointer to data array
[in]mask- pointer to mask array; mask marks bad/good (0/1) pixels
[in]rows- number of rows in all 2-d arrays
[in]cols- number of columns in all 2-d arrays
[in]rank- radius of the square region in which central pixel has a maximal value
[out]local_maxima- pointer to map of local maximums

◆ mapOfLocalMaximumsRank1Cross()

template<typename T >
size_t localextrema::mapOfLocalMaximumsRank1Cross ( const T *  data,
const mask_t *  mask,
const size_t &  rows,
const size_t &  cols,
extrim_t *  local_maxima 
)

returns map of local maximums of runk=1 cross(+) region (very special case for Chuck's algorithm).

Map of local maximum is a 2-d array of (uint16) values of data shape, with 0/+1/+2 for non-maximum / maximum in column / maximum in row, then local maximum in cross = 3.

Parameters
[in]data- pointer to data array
[in]mask- pointer to mask array; mask marks bad/good (0/1) pixels
[in]rows- number of rows in all 2-d arrays
[in]cols- number of columns in all 2-d arrays
[out]local_maxima- pointer to map of local maximums

◆ mapOfLocalMinimums()

template<typename T >
size_t localextrema::mapOfLocalMinimums ( const T *  data,
const mask_t *  mask,
const size_t &  rows,
const size_t &  cols,
const size_t &  rank,
extrim_t *  local_minima 
)

returns map of local minimums of requested rank, where rank defins a square region around central pixel [rowc-rank, rowc+rank], [colc-rank, colc+rank].

Map of local minumum is a 2-d array of (uint16) values of data shape, with 0/+1/+2/+4 for non-minumum / minumum in column / minumum in row / minimum in square of radius rank.

Parameters
[in]data- pointer to data array
[in]mask- pointer to mask array; mask marks bad/good (0/1) pixels
[in]rows- number of rows in all 2-d arrays
[in]cols- number of columns in all 2-d arrays
[in]rank- radius of the square region in which central pixel has a maximal value
[out]local_minima- pointer to map of local minimums

◆ mapOfLocalMinimums_drp()

template<typename T >
size_t localextrema::mapOfLocalMinimums_drp ( const T *  data,
const mask_t *  mask,
const size_t &  rows,
const size_t &  cols,
const size_t &  rank,
extrim_t *  local_minima,
Allocator *  allocator 
)

returns map of local minimums of requested rank, where rank defins a square region around central pixel [rowc-rank, rowc+rank], [colc-rank, colc+rank].

Map of local minumum is a 2-d array of (uint16) values of data shape, with 0/+1/+2/+4 for non-minumum / minumum in column / minumum in row / minimum in square of radius rank.

Parameters
[in]data- pointer to data array
[in]mask- pointer to mask array; mask marks bad/good (0/1) pixels
[in]rows- number of rows in all 2-d arrays
[in]cols- number of columns in all 2-d arrays
[in]rank- radius of the square region in which central pixel has a maximal value
[out]local_minima- pointer to map of local minimums

◆ mapOfThresholdMaximums()

template<typename T >
size_t localextrema::mapOfThresholdMaximums ( const T *  data,
const mask_t *  mask,
const size_t &  rows,
const size_t &  cols,
const size_t &  rank,
const double &  thr_low,
const T &  thr_high,
extrim_t *  thr_maxima 
)

returns map of local maximums for 2-threshold algorithm.

Map of local maximum is a 2-d array of (uint16) values of data shape, with 0/+1/+2/+4/+8 for masked / <thr_low / >thr_low && <thr_high / >thr_high / local maxima in runk-square +16 < -thr_low

Parameters
[in]data- pointer to data array
[in]mask- pointer to mask array; mask marks bad/good (0/1) pixels
[in]rows- number of rows in all 2-d arrays
[in]cols- number of columns in all 2-d arrays
[in]rank- radius of the square region in which central pixel has a maximal value
[in]thr_low- low threshold on intensity
[in]thr_high- high threshold on intensity
[out]map- pointer to map of local maximums

◆ numberOfExtrema()

size_t localextrema::numberOfExtrema ( const extrim_t *  map,
const size_t &  rows,
const size_t &  cols,
const extrim_t &  vsel = 7 
)

Return how many of the rows*cols entries of map equal vsel.

◆ printMatrixOfDiagIndexes()

void localextrema::printMatrixOfDiagIndexes ( const size_t &  rank)

Print to stdout a (2*rank+1) x (2*rank+1) matrix of the offsets used by evaluateDiagIndexes(): 1 for used, 0 for the central row and column, and + at the center.

◆ printVectorOfDiagIndexes()

void localextrema::printVectorOfDiagIndexes ( const size_t &  rank)

Print the size and the (i, j) pairs of evaluateDiagIndexes(rank) to stdout, ten pairs per line.

◆ vectorOfExtremeIndexes()

std::vector< TwoIndexes > localextrema::vectorOfExtremeIndexes ( const extrim_t *  map,
const size_t &  rows,
const size_t &  cols,
const extrim_t &  vsel = 7,
const size_t &  maxlen = 0 
)

Return the (row, col) indexes of all entries of map equal to vsel, in row-major order.

maxlen (rows*cols/4 if 0) only sets the reserved capacity; it does not limit the result.