+ QVector<double> r_vec(256), g_vec(256), b_vec(256), x_vec(256);
+ double max = 0.0;
+ for (unsigned i = 0; i < 256; ++i) {
+ x_vec[i] = i;
+ r_vec[i] = log(r_hist[i] + 1.0);
+ g_vec[i] = log(g_hist[i] + 1.0);
+ b_vec[i] = log(b_hist[i] + 1.0);
+
+ max = std::max(max, r_vec[i]);
+ max = std::max(max, g_vec[i]);
+ max = std::max(max, b_vec[i]);
+ }
+
+ ui->histogram->clearGraphs();
+ ui->histogram->addGraph();
+ ui->histogram->graph(0)->setData(x_vec, r_vec);
+ ui->histogram->graph(0)->setPen(QPen(Qt::red));
+ ui->histogram->graph(0)->setBrush(QBrush(QColor(255, 127, 127, 80)));
+ ui->histogram->addGraph();
+ ui->histogram->graph(1)->setData(x_vec, g_vec);
+ ui->histogram->graph(1)->setPen(QPen(Qt::green));
+ ui->histogram->graph(1)->setBrush(QBrush(QColor(127, 255, 127, 80)));
+ ui->histogram->addGraph();
+ ui->histogram->graph(2)->setData(x_vec, b_vec);
+ ui->histogram->graph(2)->setPen(QPen(Qt::blue));
+ ui->histogram->graph(2)->setBrush(QBrush(QColor(127, 127, 255, 80)));
+
+ ui->histogram->xAxis->setVisible(true);
+ ui->histogram->yAxis->setVisible(false);
+ ui->histogram->xAxis->setRange(0, 255);
+ ui->histogram->yAxis->setRange(0, max);
+ ui->histogram->replot();