C++ Template Image Processing Library. |
[Introduction]- [News]- [Download]- [Screenshots]- [Tutorial]- [Forums-Eng]- [Forums-Fr]- [Reference]- [SourceForge Repository ]

- Main Page
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

# CImgStats Struct Reference

Class used to compute basic statistics on pixel values of a CImg<T> image. More...

List of all members.

## Public Member Functions
| CImgStats ()
| Empty constructor.
| CImgStats (const CImgStats &stats)
| Copy constructor.
template<typename T>
| CImgStats (const CImg< T > &img, const bool compute_variance=true)
| Constructor that computes statistics of an input image `img`.
template<typename T>
| CImgStats (const CImgl< T > &list, const bool compute_variance=true)
| Constructor that computes statistics of an input image list `list`.
CImgStats & | operator= (const CImgStats &stats)
| Assignement operator.
CImgStats & | assign (const CImgStats &stats)
| In-place version of the corresponding constructor.
template<typename T>
CImgStats & | assign (const CImg< T > &img, const bool compute_variance=true)
| In-place version of the corresponding constructor.
template<typename T>
CImgStats & | assign (const CImgl< T > &list, const bool compute_variance=true)
| In-place version of the corresponding constructor.
const CImgStats & | print (const char *title=0) const
| Print the current statistics.
## Public Attributes
double | min
| Minimum of the pixel values.
double | max
| Maximum of the pixel values.
double | mean
| Mean of the pixel values.
double | variance
| Variance of the pixel values.
int | xmin
| X-coordinate of the pixel with minimum value.
int | ymin
| Y-coordinate of the pixel with minimum value.
int | zmin
| Z-coordinate of the pixel with minimum value.
int | vmin
| V-coordinate of the pixel with minimum value.
int | lmin
| Image number (for a list) containing the minimum pixel.
int | xmax
| X-coordinate of the pixel with maximum value.
int | ymax
| Y-coordinate of the pixel with maximum value.
int | zmax
| Z-coordinate of the pixel with maximum value.
int | vmax
| V-coordinate of the pixel with maximum value.
int | lmax
| Image number (for a list) containing the maximum pixel.

## Detailed Description

Class used to compute basic statistics on pixel values of a CImg<T> image.

Constructing a CImgStats instance from an image CImg<T> or a list CImgl<T> will compute the minimum, maximum and average pixel values of the input object. Optionally, the variance of the pixel values can be computed. Coordinates of the pixels whose values are minimum and maximum are also stored. The example below shows how to use CImgStats objects to retrieve simple statistics of an image :

          const CImg<float> img("my_image.jpg");                 // Read JPEG image file.
          const CImgStats stats(img);                            // Compute basic statistics on the image.
          stats.print("My statistics");                          // Display statistics.
          std::printf("Max-Min = %lf",stats.max-stats.min);      // Compute the difference between extremum values.

Note that statistics are computed by considering the set of scalar values of the image pixels. No vector-valued statistics are computed.

## Constructor & Destructor Documentation

CImgStats | ( | const CImg< T > & | img,
|  | const bool | compute_variance = `true`
| ) |

  | Constructor that computes statistics of an input image `img`. Parameters:
  | img | The input image.
  | compute_variance | If true, the `variance` field is computed, else it is set to 0.

CImgStats | ( | const CImgl< T > & | list,
|  | const bool | compute_variance = `true`
| ) |

  | Constructor that computes statistics of an input image list `list`. Parameters:
  | list | The input list of images.
  | compute_variance | If true, the `variance` field is computed, else it is set to 0.

## Member Function Documentation

const CImgStats& print | ( | const char * | title = `0` | ) | const

| Print the current statistics. Printing is done on the standart error output.

The CImg Library - C++ Template Image Processing Library