27 #ifndef CORE_HISTOGRAM_H 28 #define CORE_HISTOGRAM_H 189 void init(
double min_val,
double max_val,
int n_steps);
205 #define INSERT_VALUE(histogram,value) \ 207 if (value == histogram.hmax) { \ 208 size_t iii = XSIZE(histogram) - 1; \ 209 ++DIRECT_A1D_ELEM(histogram, iii); \ 210 ++histogram.no_samples; \ 212 size_t iii = (size_t) ((value - histogram.hmin) * histogram.istep_size); \ 213 if (iii >= 0 && iii < XSIZE(histogram)) \ 215 ++DIRECT_A1D_ELEM(histogram, iii); \ 216 ++histogram.no_samples; \ 274 i =
XSIZE(*
this) - 1;
277 double aux=(v -
hmin) * istep_size;
278 i = (int)
FLOOR(aux);
281 if (i < 0 || i >= (
int)
XSIZE(*
this))
376 double getProbability(
double x);
396 int val2Index(
double value)
const;
399 void selfNormalize();
402 friend std::ostream &
operator << (std::ostream &_out,
457 for (
int i=1;
i<imax;
i++)
463 hist.
init(min, max, no_steps);
465 for (
int i=1;
i<imax;
i++)
487 double min,
double max,
int no_steps)
489 hist.
init(min, max, no_steps);
494 for (
size_t n=0;
n<
nmax;
n+=4, ptr+=4)
515 double min,
double max,
int no_steps);
530 hist.
init(min, max, no_steps);
595 double min_val = hist.
percentil(percentil_out / 2);
596 double max_val = hist.
percentil(100 - percentil_out / 2);
597 return max_val - min_val;
609 double eff0 = hist.
percentil(percentil_out / 2);
610 double effF = hist.
percentil(100 - percentil_out / 2);
636 const int hist_steps = 200;
644 for (
int i = 1;
i < hist_steps;
i++)
652 for (
int current_bin = 1; current_bin < bins; current_bin++)
770 void init(
double imin_val,
double imax_val,
int in_steps,
771 double jmin_val,
double jmax_val,
int jn_steps);
823 j = (int)
FLOOR((u - jmin) / jstep_size);
825 if (i < 0 || i >= IstepNo())
828 if (j < 0 || j >= JstepNo())
846 u = jmin + j * jstep_size;
970 v1.computeDoubleMinMax(min1, max1)
974 v2.computeDoubleMinMax(min2, max2);
976 compute_hist(v1, v2, hist, min1, max1, min2, max2, no_steps1, no_steps2);
988 double m1,
double M1,
double m2,
double M2,
int no_steps1,
994 hist.
init(m1, M1, no_steps1, m2, M2, no_steps2);
void insert_value(double v, double u)
void val2index(double v, int &i) const
void min(Image< double > &op1, const Image< double > &op2)
double KLDistance(const Histogram1D &h1, const Histogram1D &h2)
#define REPORT_ERROR(nerr, ErrormMsg)
#define INSERT_VALUE(histogram, value)
double mass_below(double value)
MultidimArray< double > probXLessThanx
double detectability_error(const Histogram1D &h1, const Histogram1D &h2)
void assign(const Histogram1D &H)
void init(double imin_val, double imax_val, int in_steps, double jmin_val, double jmax_val, int jn_steps)
Histogram1D & operator=(const Histogram1D &H)
double percentil(double percent_mass)
void index2val(double i, double j, double &v, double &u) const
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY_ptr(v, n, ptr)
Incorrect MultidimArray size.
void init(double min_val, double max_val, int n_steps)
void insert_value(double val)
#define DIRECT_A1D_ELEM(v, i)
friend std::ostream & operator<<(std::ostream &o, const Histogram1D &hist)
void index2val(double i, double &v) const
Histogram1D(const Histogram1D &H)
void reject_outliers(T &v, double percentil_out=0.25)
void val2index(double v, double u, int &i, int &j) const
bool sameShape(const MultidimArrayBase &op) const
void computeDoubleMinMax(double &minval, double &maxval) const
Histogram2D(const Histogram2D &H)
void max(Image< double > &op1, const Image< double > &op2)
#define FOR_ALL_DIRECT_ELEMENTS_IN_MULTIDIMARRAY(v)
#define DIRECT_MULTIDIM_ELEM(v, n)
void compute_hist(const MultidimArray< T > &array, Histogram1D &hist, int no_steps)
MultidimArray< double > __binsRightLimits
double effective_range(const T &v, double percentil_out=0.25)
double operator()(int i) const
Get value.
double mass_above(double value)
void write(const FileName &fn, MDLabel=MDL_X, MDLabel=MDL_COUNT)
void histogram_equalization(MultidimArray< T > &v, int bins=8)
MultidimArray< double > x
#define FOR_ALL_ELEMENTS_IN_ARRAY2D_BETWEEN(corner1, corner2)