20 const QRgb &rgbBackground)
const
34 bin = qFloor (FIRST_NON_EMPTY_BIN_AT_START () + s * (LAST_NON_EMPTY_BIN_AT_END () - FIRST_NON_EMPTY_BIN_AT_START ()));
42 double histogramBins [],
45 int &maxBinCount)
const
50 histogramBins [bin] = 0;
57 for (
int x = 0; x < image.width(); x++) {
58 for (
int y = 0; y < image.height(); y++) {
60 QColor pixel (image.pixel (x, y));
68 (LAST_NON_EMPTY_BIN_AT_END () >= bin));
69 ++(histogramBins [bin]);
71 if (histogramBins [bin] > maxBinCount) {
72 maxBinCount = qFloor (histogramBins [bin]);
84 double s = double (bin - FIRST_NON_EMPTY_BIN_AT_START ()) / double (LAST_NON_EMPTY_BIN_AT_END () - FIRST_NON_EMPTY_BIN_AT_START ());
85 s = qMin (qMax (s, 0.0), 1.0);
#define ENGAUGE_ASSERT(cond)
Drop in replacement for Q_ASSERT.
void generate(const ColorFilter &filter, double histogramBins[], ColorFilterMode colorFilterMode, const QImage &image, int &maxBinCount) const
Generate the histogram.
ColorFilterHistogram()
Single constructor.
int valueFromBin(const ColorFilter &filter, ColorFilterMode colorFilterMode, int bin)
Inverse of binFromPixel.
static int HISTOGRAM_BINS()
Number of histogram bins.
int binFromPixel(const ColorFilter &filter, ColorFilterMode colorFilterMode, const QColor &pixel, const QRgb &rgbBackground) const
Compute histogram bin number from pixel according to filter.
Class for filtering image to remove unimportant information.
QRgb marginColor(const QImage *image) const
Identify the margin color of the image, which is defined as the most common color in the four margins...
int zeroToOneToValue(ColorFilterMode colorFilterMode, double s) const
Inverse of pixelToZeroToOneOrMinusOne.
double pixelToZeroToOneOrMinusOne(ColorFilterMode colorFilterMode, const QColor &pixel, QRgb rgbBackground) const
Return pixel converted according to the current filter parameter, normalized to zero to one.