BRL-CAD
stat.h
Go to the documentation of this file.
1 /* S T A T . H
2  * BRL-CAD
3  *
4  * Copyright (c) 2011-2024 United States Government as represented by
5  * the U.S. Army Research Laboratory.
6  *
7  * This library is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public License
9  * version 2.1 as published by the Free Software Foundation.
10  *
11  * This library is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this file; see the file named COPYING for more
18  * information.
19  */
20 /** @addtogroup icv_stat
21  *
22  * Image statistics and histogram routines.
23  *
24  */
25 
26 #ifndef ICV_STAT_H
27 #define ICV_STAT_H
28 
29 #include "common.h"
30 #include <stddef.h> /* for size_t */
31 #include "icv/defines.h"
32 
33 __BEGIN_DECLS
34 
35 /** @{ */
36 /** @file icv/stat.h */
37 
38 /**
39  * This function calculates the histogram of different channels
40  * separately.
41  *
42  * @param img Image of which histogram is to found.
43  * @param n_bins number of bins required.
44  * @return Histogram of size_t type array. This 2-dimension array
45  * is of size c X n_bins where c is the channels in the image.
46  *
47  */
48 ICV_EXPORT size_t **icv_hist(icv_image_t* img, size_t n_bins);
49 
50 /**
51  * Finds the minimum value in each channel of the image.
52  *
53  * @return a double array of size channels. Each element contains min
54  * value of the channel.
55  *
56  * e.g. min = icv_min(bif);
57  * min[0] gives the minimum value of all the pixels in first bin.
58  * and so on.
59  *
60  */
61 ICV_EXPORT double *icv_min(icv_image_t* img);
62 
63 /**
64  * Finds the average value in each channel of the image.
65  *
66  * @return a double array of size channels. Each elements contains
67  * average value of the channel.
68  *
69  * e.g. mean = icv_mean(bif);
70  * mean[0] gives the average value of all the pixels in first channel
71  * and so on.
72  *
73  */
74 ICV_EXPORT double *icv_mean(icv_image_t* img);
75 
76 /**
77  * Finds the sum of all the pixel values for each channel of the image
78  *
79  * @return a double array of size channels. Each element contains sum
80  * value of the channel.
81  *
82  * e.g. sum = icv_sum(bif);
83  * sum[0] gives the sum of all the pixels in first channel
84  * and so on.
85  *
86  */
87 ICV_EXPORT double *icv_sum(icv_image_t* img);
88 
89 /**
90  * Finds the max value in each channel of the image.
91  *
92  * @return a double array of size channels. Each element contains max
93  * value of the channel.
94  *
95  * e.g. max = icv_max(bif);
96  * max[0] gives the maximum value of all the pixels in first bin.
97  * and so on.
98  *
99  */
100 ICV_EXPORT double *icv_max(icv_image_t* img);
101 
102 /**
103  * Calculates mode of the values of each channel.
104  * Mode value are calculated for quantified data which is sent as
105  * bins(histogram Information). For any image mode is a 'c' length
106  * array where c is the number of channels.
107  *
108  * To calculate the mode of an icv_image, a default call is as follows
109  * icv_mode(img, icv_hist(img, n_bins), n_bins);
110  *
111  * This call first calculates the histogram of the image. then finds
112  * the mode values from histogram of each channel.
113  *
114  */
115 ICV_EXPORT int *icv_mode(icv_image_t* img, size_t** bins, size_t n_bins);
116 
117 /**
118  * Calculates median of the values of each channel.
119  * Median value are calculated for quantified data which is sent as
120  * bins(histogram information). For any image mode is a 'c' length
121  * array, where c is the number of channels.
122  *
123  * To calculate the median of an icv_image, a default call is as
124  * follows :
125  * icv_median(img, icv_hist(img, n_bins), n_bins);
126  *
127  * This call first calculates the histogram of the image. then finds
128  * the mode values from histogram of each channel.
129  *
130  */
131 ICV_EXPORT int *icv_median(icv_image_t* img, size_t** bins, size_t n_bins);
132 
133 /**
134  * Calculates the skewness in data.
135  *
136  * To calculate the skewness in an icv_image, a default call is as
137  * follows :
138  * icv_skew(img, icv_hist(img, n_bins), n_bins);
139  *
140  * @return c length double array where c is the number of channels in
141  * the img
142  */
143 ICV_EXPORT double *icv_skew(icv_image_t* img, size_t** bins, size_t n_bins);
144 
145 /**
146  * Calculates the variance in data.
147  *
148  * To calculate the variance in an icv_image, a default call is as
149  * follows :
150  * icv_variance(img, icv_hist(img, n_bins), n_bins);
151  *
152  * @return c length double array where c is the number of channels in
153  * the img
154  */
155 ICV_EXPORT double *icv_var(icv_image_t* img, size_t** bins, size_t n_bins);
156 
157 /** @} */
158 
159 __END_DECLS
160 
161 #endif /* ICV_STAT_H */
162 
163 /*
164  * Local Variables:
165  * tab-width: 8
166  * mode: C
167  * indent-tabs-mode: t
168  * c-file-style: "stroustrup"
169  * End:
170  * ex: shiftwidth=4 tabstop=8
171  */
Header file for the BRL-CAD common definitions.
double * icv_sum(icv_image_t *img)
int * icv_mode(icv_image_t *img, size_t **bins, size_t n_bins)
double * icv_min(icv_image_t *img)
double * icv_mean(icv_image_t *img)
double * icv_var(icv_image_t *img, size_t **bins, size_t n_bins)
double * icv_max(icv_image_t *img)
double * icv_skew(icv_image_t *img, size_t **bins, size_t n_bins)
size_t ** icv_hist(icv_image_t *img, size_t n_bins)
int * icv_median(icv_image_t *img, size_t **bins, size_t n_bins)