void GridClassifier::populateHistogramBins (const QImage &image, const Transformation &transformation, double xMin, double xMax, double yMin, double yMax) { LOG4CPP_INFO_S ((*mainCat)) << "GridClassifier::populateHistogramBins"; ColorFilter filter; QRgb rgbBackground = filter.marginColor (&image); for (int x = 0; x < image.width(); x++) { for (int y = 0; y < image.height(); y++) { QColor pixel = image.pixel (x, y); // Skip pixels with background color if (!filter.colorCompare (rgbBackground, pixel.rgb ())) { // Add this pixel to histograms QPointF posGraph; transformation.transformScreenToRawGraph (QPointF (x, y), posGraph); if (transformation.modelCoords().coordsType() == COORDS_TYPE_POLAR) { // If out of the 0 to period range, the theta value must shifted by the period to get into that range while (posGraph.x() < xMin) { posGraph.setX (posGraph.x() + transformation.modelCoords().thetaPeriod()); } while (posGraph.x() > xMax) { posGraph.setX (posGraph.x() - transformation.modelCoords().thetaPeriod()); } } int binX = binFromCoordinate (posGraph.x(), xMin, xMax); int binY = binFromCoordinate (posGraph.y(), yMin, yMax); ENGAUGE_ASSERT (0 <= binX); ENGAUGE_ASSERT (0 <= binY); ENGAUGE_ASSERT (binX < m_numHistogramBins); ENGAUGE_ASSERT (binY < m_numHistogramBins); // Roundoff error in log scaling may let bin go just outside legal range binX = qMin (binX, m_numHistogramBins - 1); binY = qMin (binY, m_numHistogramBins - 1); ++m_binsX [binX]; ++m_binsY [binY]; } } } }
QRgb DlgSettingsColorFilter::createThread () { LOG4CPP_INFO_S ((*mainCat)) << "DlgSettingsColorFilter::createThread"; // Get background color QImage image = cmdMediator().document().pixmap().toImage(); ColorFilter filter; QRgb rgbBackground = filter.marginColor(&image); // Only create thread once if (m_filterThread == 0) { m_filterThread = new DlgFilterThread (cmdMediator().document().pixmap(), rgbBackground, *this); m_filterThread->start(); // Now that thread is started, we can use signalApplyFilter } return rgbBackground; }