|
OpenZGY/C++ API and Internals (ALPHA)
Access seismic data stored in ZGY format.
|
Histogram of all sample values on the file. More...
#include <api.h>
Public Member Functions | |
| SampleHistogram (std::int64_t samplecount_in, double minvalue_in, double maxvalue_in, const std::vector< std::int64_t > &bins_in) | |
| Create a new instance with all contents filled in. | |
Public Attributes | |
| std::int64_t | samplecount |
| Sum of counts of all bins. | |
| double | minvalue |
| Center value of data in first bin. | |
| double | maxvalue |
| Center value of data in last bin. | |
| std::vector< std::int64_t > | bins |
| array of counts by bin | |
Histogram of all sample values on the file.
The histogram is described by the fixed total number of bins, the center value of the samples in the first bin, and the center value of the samples in the last bin.
The width of each bin is given by (max - min) / (nbins - 1). Bin 0 holds samples with values min_ +/-binwidth/2.
This means that the total range of samples that can be represented in the histogram is actually min-binwidth/2 to max+binwidth/2, which is slightly larger than just min..max unless each of the bins can only hold a single value (e.g. data converted from 8-bit storage, in 256 bins).
This definition has some subtle effects, best illustrated by a few examples.
If the source data is ui8_t, the logical range is 0..255. Assume nbins=256. This gives binwidth=1, and the true range of the histogram -0.5..+255.5. But since the input is integral, the actual range is just 0..255 inclusive. Try to fill the histogram with evenly distrubuted random data and you end up with each bin having roughly the same number of elements.
Now consider ui16_t, range 0..65535 and nbins is still 256. This gives binwidth=257, not 256. The true range of the histogram is -128.5..+65663.5. Try to fill the histogram with evenly distrubuted random data and you end up with the first and the last bin having approximately half as many elements as all the others. This is not really a problem, but may seem a bit surprising.
1.8.17