Xmipp
v3.23.11-Nereus
|
#include <histogram.h>
Public Member Functions | |
Histogram1D () | |
Histogram1D (const Histogram1D &H) | |
void | clear () |
Histogram1D & | operator= (const Histogram1D &H) |
void | assign (const Histogram1D &H) |
void | init (double min_val, double max_val, int n_steps) |
void | insert_value (double val) |
double | percentil (double percent_mass) |
double | mass_below (double value) |
double | mass_above (double value) |
void | write (const FileName &fn, MDLabel=MDL_X, MDLabel=MDL_COUNT) |
void | val2index (double v, int &i) const |
void | index2val (double i, double &v) const |
double | hist_min () const |
double | hist_max () const |
double | step () const |
int | stepNo () const |
double | sampleNo () const |
double | entropy () const |
Public Member Functions inherited from MultidimArray< double > | |
MultidimArray () | |
MultidimArray (size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, double *data) | |
MultidimArray (size_t Ndim, int Zdim, int Ydim, int Xdim) | |
MultidimArray (int Zdim, int Ydim, int Xdim) | |
MultidimArray (int Ydim, int Xdim) | |
MultidimArray (int Xdim) | |
MultidimArray (const MultidimArray< double > &V) | |
MultidimArray (MultidimArray< double > &&V) noexcept | |
MultidimArray (const Matrix1D< double > &V) | |
MultidimArray (const std::vector< double > &vector) | |
virtual | ~MultidimArray () |
void | clear () |
void | coreInit () noexcept |
void | swap (MultidimArray< double > &other) noexcept |
void | coreAllocate (size_t _ndim, int _zdim, int _ydim, int _xdim) |
void | coreAllocate () |
void | coreAllocateReuse () |
FILE * | mmapFile (double *&_data, size_t nzyxDim) const |
void | coreDeallocate () noexcept |
void | alias (const MultidimArray< double > &m) |
void | aliasRow (const MultidimArray< double > &m, size_t select_row) |
void | aliasSlice (const MultidimArray< double > &m, size_t select_slice) |
void | aliasImageInStack (const MultidimArray< double > &m, size_t select_image) |
void | resize (size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim, bool copy=true) |
void | resize (const MultidimArray< T1 > &v, bool copy=true) |
void | resizeNoCopy (const MultidimArray< T1 > &v) |
void | checkDimensionWithDebug (int dim, const char *file, int line) const |
void | selfWindow (int n0, int z0, int y0, int x0, int nF, int zF, int yF, int xF, double init_value=0) |
void | selfWindow (int z0, int y0, int x0, int zF, int yF, int xF, double init_value=0) |
void | selfWindow (int y0, int x0, int yF, int xF, double init_value=0) |
void | selfWindow (int x0, int xF, double init_value=0) |
void | window (MultidimArray< T1 > &result, int n0, int z0, int y0, int x0, int nF, int zF, int yF, int xF, T1 init_value=0) const |
void | window (MultidimArray< T1 > &result, int z0, int y0, int x0, int zF, int yF, int xF, T1 init_value=0) const |
void | window (MultidimArray< T1 > &result, int y0, int x0, int yF, int xF, T1 init_value=0) const |
void | window (MultidimArray< T1 > &result, int x0, int xF, T1 init_value=0) const |
void | patch (MultidimArray< double > patchArray, int x, int y) |
double & | operator() (const Matrix1D< double > &v) const |
double & | operator() (const Matrix1D< int > &v) const |
double & | operator() (size_t n, int k, int i, int j) const |
double & | operator() (int k, int i, int j) const |
double & | operator() (int i, int j) const |
double & | operator() (int i) const |
double & | operator[] (size_t i) const |
void * | getArrayPointer () const |
void | getImage (size_t n, MultidimArray< double > &M, size_t n2=0) const |
void | getSlice (int k, MultidimArray< T1 > &M, char axis='Z', bool reverse=false, size_t n=0) const |
void | getSliceAsMatrix (size_t k, Matrix2D< double > &m) const |
void | getAliasAsRowVector (Matrix1D< double > &m) const |
void | setSlice (int k, const MultidimArray< T1 > &v, size_t n=0) |
void | reslice (MultidimArray< T1 > &out, AxisView face, bool flip=false, size_t n=0) const |
void | reslice (AxisView face, bool flip=false, size_t n=0) |
void | getCol (size_t j, MultidimArray< double > &v) const |
void | setCol (size_t j, const MultidimArray< double > &v) |
void | getRow (size_t i, MultidimArray< double > &v) const |
void | setRow (int i, const MultidimArray< double > &v) |
void | getReal (MultidimArray< double > &realImg) const |
void | getImag (MultidimArray< double > &imagImg) const |
void | toPhysical (int k_log, int i_log, int j_log, int &k_phys, int &i_phys, int &j_phys) const |
void | toPhysical (int i_log, int j_log, int &i_phys, int &j_phys) const |
void | toPhysical (int i_log, int &i_phys) const |
void | toLogical (int k_phys, int i_phys, int j_phys, int &k_log, int &i_log, int &j_log) const |
void | toLogical (int i_phys, int j_phys, int &i_log, int &j_log) const |
void | toLogical (int i_phys, int &i_log) const |
double | interpolatedElement3D (double x, double y, double z, double outside_value=(double) 0) const |
double | interpolatedElement2D (double x, double y, double outside_value=(double) 0) const |
double | interpolatedElement2DOutsideZero (double x, double y) const |
double | interpolatedElement1D (double x, double outside_value=(double) 0) const |
double | interpolatedElementBSpline3D (double x, double y, double z, int SplineDegree=3) const |
double | interpolatedElementBSpline2D (double x, double y, int SplineDegree=3) const |
double | interpolatedElementBSpline2D_Degree3 (double x, double y) const |
double | interpolatedElementBSpline1D (double x, int SplineDegree=3) const |
void | printStats (std::ostream &out=std::cout) const |
double | computeMax () const |
void | maxIndex (int &jmax) const |
void | maxIndex (size_t &lmax, int &kmax, int &imax, int &jmax) const |
double | computeMin () const |
void | minIndex (int &lmin, int &kmin, int &imin, int &jmin) const |
void | minIndex (int &kmin, int &imin, int &jmin) const |
void | minIndex (int &imin, int &jmin) const |
void | minIndex (int &jmin) const |
void | computeDoubleMinMax (double &minval, double &maxval) const |
void | computeDoubleMinMaxRange (double &minval, double &maxval, size_t offset, size_t size) const |
double | computeAvg () const |
double | computeStddev () const |
void | computeStats (double &avg, double &stddev, double &minval, double &maxval) const |
void | computeStats (double &avg, double &stddev, double &min_val, double &max_val, Matrix1D< int > &corner1, Matrix1D< int > &corner2, size_t n=0) |
void | computeAvgStdev (U &avg, U &stddev) const |
void | computeAvgStdev_within_binary_mask (const MultidimArray< int > &mask, double &avg, double &stddev) const |
void | computeMedian_within_binary_mask (const MultidimArray< int > &mask, double &median) const |
double | computeMedian () const |
void | rangeAdjust (double minF, double maxF) |
void | rangeAdjust (double minF, double maxF, MultidimArray< int > &mask) |
void | rangeAdjust (const MultidimArray< double > &example, const MultidimArray< int > *mask=NULL) |
void | statisticsAdjust (U avgF, U stddevF) |
void | initConstant (double val) |
void | initZeros (const MultidimArray< T1 > &op) |
void | initZeros () |
void | initZeros (size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim) |
void | initZeros (int Xdim) |
void | initZeros (int Ydim, int Xdim) |
void | initZeros (int Zdim, int Ydim, int Xdim) |
void | initLinear (double minF, double maxF, int n=1, const String &mode="incr") |
void | initRandom (double op1, double op2, RandomMode mode=RND_UNIFORM) |
void | addNoise (double op1, double op2, const String &mode="uniform", double df=3.) const |
MultidimArray< double > | operator+ (const MultidimArray< double > &op1) const |
MultidimArray< double > | operator- (const MultidimArray< double > &op1) const |
MultidimArray< double > | operator* (const MultidimArray< double > &op1) const |
MultidimArray< double > | operator/ (const MultidimArray< double > &op1) const |
void | operator+= (const MultidimArray< double > &op1) |
void | operator-= (const MultidimArray< double > &op1) |
void | operator*= (const MultidimArray< double > &op1) |
void | operator/= (const MultidimArray< double > &op1) |
double | dotProduct (const MultidimArray< double > &op1) |
MultidimArray< double > | operator+ (double op1) const |
MultidimArray< double > | operator- (double op1) const |
MultidimArray< double > | operator* (double op1) const |
MultidimArray< double > | operator/ (double op1) const |
void | operator+= (const double &op1) |
void | operator-= (const double &op1) |
void | operator*= (const double &op1) |
void | operator/= (const double &op1) |
void | equal (double op1, MultidimArray< char > &result) const |
MultidimArray< double > | operator- () const |
bool | equal (const MultidimArray< double > &op, double accuracy=XMIPP_EQUAL_ACCURACY) const |
MultidimArray< double > & | operator= (const MultidimArray< double > &op1) |
MultidimArray< double > & | operator= (MultidimArray< double > &&other) noexcept |
MultidimArray< double > & | operator= (const Matrix2D< double > &op1) |
void | copy (Matrix2D< double > &op1) const |
double *** | adaptForNumericalRecipes3D (size_t n=0) const |
void | killAdaptationForNumericalRecipes3D (double ***m) const |
double ** | adaptForNumericalRecipes2D (size_t n=0) const |
double * | adaptForNumericalRecipes22D () const |
void | loadFromNumericalRecipes2D (double **m, int Ydim, int Xdim) |
void | killAdaptationForNumericalRecipes2D (double **m) const |
void | killAdaptationForNumericalRecipes22D (double **m) const |
double * | adaptForNumericalRecipes1D () const |
void | killAdaptationForNumericalRecipes1D (double *m) const |
void | centerOfMass (Matrix1D< double > ¢er, void *mask=NULL, size_t n=0) |
void | sort (MultidimArray< double > &result) const |
void | indexSort (MultidimArray< int > &indx) const |
void | cumlativeDensityFunction (MultidimArray< double > &cdf) |
void | threshold (const String &type, double a, double b=0, MultidimArray< int > *mask=NULL) |
size_t | countThreshold (const String &type, double a, double b, MultidimArray< int > *mask=NULL) |
void | substitute (double oldv, double newv, double accuracy=XMIPP_EQUAL_ACCURACY, MultidimArray< int > *mask=NULL) |
void | randomSubstitute (double oldv, double avgv, double sigv, double accuracy=XMIPP_EQUAL_ACCURACY, MultidimArray< int > *mask=NULL) |
void | binarize (double val=0, double accuracy=XMIPP_EQUAL_ACCURACY, MultidimArray< int > *mask=NULL) |
void | binarizeRange (double valMin=0, double valMax=255, MultidimArray< int > *mask=NULL) |
void | selfROUND () |
void | selfCEIL () |
void | selfFLOOR () |
void | selfABS () |
void | selfNormalizeInterval (double minPerc=0.25, double maxPerc=0.75, int Npix=1000) |
void | selfSQRT () |
double | sum () const |
double | sum2 () const |
void | selfLog10 () |
void | selfLog () |
void | selfReverseX () |
void | selfReverseY () |
void | selfReverseZ () |
void | profile (int x0, int y0, int xF, int yF, int N, MultidimArray< double > &profile) const |
void | showWithGnuPlot (const String &xlabel, const String &title) |
void | edit () |
void | write (const FileName &fn) const |
Public Member Functions inherited from MultidimArrayBase | |
virtual | ~MultidimArrayBase () |
int | getDim () const |
void | setMmap (bool mmap) |
void | maxIndex (ArrayCoord &pos) const |
void | maxIndex (int &kmax, int &imax, int &jmax) const |
void | maxIndex (int &imax, int &jmax) const |
void | maxIndex (int &jmax) const |
void | printShape (std::ostream &out=std::cout) const |
void | setNdim (int Ndim) |
void | setZdim (int Zdim) |
void | setYdim (int Ydim) |
void | setXdim (int Xdim) |
void | setDimensions (int Xdim, int Ydim, int Zdim, size_t Ndim) |
void | setDimensions (ArrayDim &newDim) |
void | getDimensions (size_t &Xdim, size_t &Ydim, size_t &Zdim, size_t &Ndim) const |
void | getDimensions (ArrayDim &idim) const |
ArrayDim | getDimensions () const |
void | getDimensions (int *size) const |
size_t | getSize () const |
void | resize (size_t Zdim, size_t Ydim, size_t Xdim) |
void | resize (size_t Ydim, size_t Xdim) |
void | resize (size_t Xdim) |
void | resize (ArrayDim &adim, bool copy=true) |
void | resizeNoCopy (size_t Ndim, size_t Zdim, size_t Ydim, size_t Xdim) |
void | resizeNoCopy (size_t Zdim, size_t Ydim, size_t Xdim) |
void | resizeNoCopy (size_t Ydim, size_t Xdim) |
void | resizeNoCopy (size_t Xdim) |
size_t | rowNumber () const |
size_t | colNumber () const |
void | copyShape (const MultidimArrayBase &m) |
bool | sameShape (const MultidimArrayBase &op) const |
void | setXmippOrigin () |
void | resetOrigin () |
void | moveOriginTo (int k, int i, int j) |
void | moveOriginTo (int i, int j) |
int | startingZ () const |
int | finishingZ () const |
int | startingY () const |
int | finishingY () const |
int | startingX () const |
int | finishingX () const |
bool | isCorner (const Matrix1D< double > &v) const |
bool | outside (int k, int i, int j) const |
bool | outside (int i, int j) const |
bool | outside (int i) const |
bool | outside (const Matrix1D< double > &r) const |
Public Attributes | |
double | hmin |
double | hmax |
double | step_size |
double | istep_size |
int | no_samples |
Public Attributes inherited from MultidimArray< double > | |
double * | data |
Public Attributes inherited from MultidimArrayBase | |
bool | destroyData |
size_t | ndim |
size_t | zdim |
size_t | ydim |
size_t | xdim |
size_t | yxdim |
size_t | zyxdim |
size_t | nzyxdim |
int | zinit |
int | yinit |
int | xinit |
bool | mmapOn |
FILE * | mFd |
size_t | nzyxdimAlloc |
Friends | |
std::ostream & | operator<< (std::ostream &o, const Histogram1D &hist) |
Histograms with 1 parameter
This class of histograms are the usual ones where we want to count the number of elements within a certain range of a variable, then we make the histogram of that variable. The range is divided into small subranges within which the values will be grouped. Any value outside the global range will not be counted in the histogram.
To see exactly which is the division between subranges let's have a look on the following example where an histogram between 0 and 2 is computed with 5 steps.
The border points are 0.0, 0.4, 0.8, 1.2, 1.6 and 2.0. The brackets and parenthesis try to represent where the border point belongs to, and the numbers within the bars are the index of each bar whithin the histogram. The height of each bar is the number of times that a value within that subrange has been inserted. Be careful that this is not a probability density function (pdf), to be so it should be divided by the total number of values inserted.
The simplest way of computing a histograms is the following:
The following example shows how to work with the histograms. In it we will compute which is the central range within which the 95% of the values of a matrix are comprised. This example could be even simplified by using the function compute_hist but it has been kept like this to show the idea behind the histograms
Definition at line 121 of file histogram.h.
|
inline |
Empty constructor
Creates an empty histogram. Before using it you must initialise it with init.
Definition at line 140 of file histogram.h.
|
inline |
Copy constructor
Makes an exact copy of the given histogram into another histogram.
Definition at line 153 of file histogram.h.
void Histogram1D::assign | ( | const Histogram1D & | H | ) |
Another function for assignament.
Definition at line 66 of file histogram.cpp.
|
virtual |
Empties an histogram
Remember to initialise it before using it again.
Implements MultidimArrayBase.
Definition at line 40 of file histogram.cpp.
double Histogram1D::entropy | ( | ) | const |
Measure the entropy of this histogram.
Before computing the entropy, the histogram is corrected with a Laplace correction. The entropy is computed as sum(-p*log(p))
Definition at line 238 of file histogram.cpp.
|
inline |
Maximum value where the histogram is defined
Definition at line 317 of file histogram.h.
|
inline |
Minimum value where the histogram is defined
Definition at line 306 of file histogram.h.
|
inline |
Index –> Value
Given the code of one interval, this function returns the value of its starting point (its left border point). If the intervals are defined as [a,b), this function returns a.
Definition at line 295 of file histogram.h.
void Histogram1D::init | ( | double | min_val, |
double | max_val, | ||
int | n_steps | ||
) |
Initialisation of the histogram
This is the operation which allows the histogram to be used. This should be performed before inserting any value in it. The information given to this initialisation is the range within which the values will be counted, and the number of steps (discrete bars) in this range. If the value is outside this range it will not be taken into account although we have asked for its insertion in the histogram.
Definition at line 71 of file histogram.cpp.
void Histogram1D::insert_value | ( | double | val | ) |
Insert a value within histogram
The right interval is chosen according to the initialisation of the histogram and the count of elements in that interval is incremented by 1. If the value lies outside the global range of the histogram nothing is done.
Definition at line 83 of file histogram.cpp.
|
inline |
Mass above
Returns the number of points which are above a certain value
Definition at line 245 of file histogram.h.
double Histogram1D::mass_below | ( | double | value | ) |
Mass below
Returns the number of points which are below a certain value
Definition at line 215 of file histogram.cpp.
Histogram1D & Histogram1D::operator= | ( | const Histogram1D & | H | ) |
Assignment
Definition at line 51 of file histogram.cpp.
double Histogram1D::percentil | ( | double | percent_mass | ) |
Returns the percentil value
This function returns the value within the range for which a given percent mass of the total number of elements are below it. For instance, if we have 120 values distributed between 0 and 45, and we ask for the percentil of 60%, the returned value is that within 0 and 45 for which 120 * 0.6 = 72 elements are smaller than it.
Definition at line 160 of file histogram.cpp.
|
inline |
Number of samples introduced in the histogram
Definition at line 350 of file histogram.h.
|
inline |
Step size for the histogram
Definition at line 328 of file histogram.h.
|
inline |
Number of steps in the histogram
Definition at line 339 of file histogram.h.
|
inline |
Value –> Index
Given a value it returns the code of the interval where it should be counted. If it is outside the global range of the histogram it returns -1
Definition at line 271 of file histogram.h.
void Histogram1D::write | ( | const FileName & | fn, |
MDLabel | mdlValue = MDL_X , |
||
MDLabel | mdlCount = MDL_COUNT |
||
) |
Write an histogram to disk.
Definition at line 129 of file histogram.cpp.
|
friend |
Show an histogram
The first column is the value associated to each histogram measure. The second one is the histogram measure.
Definition at line 115 of file histogram.cpp.
double Histogram1D::hmax |
Definition at line 126 of file histogram.h.
double Histogram1D::hmin |
Definition at line 125 of file histogram.h.
double Histogram1D::istep_size |
Definition at line 128 of file histogram.h.
int Histogram1D::no_samples |
Definition at line 129 of file histogram.h.
double Histogram1D::step_size |
Definition at line 127 of file histogram.h.