Exemplo n.º 1
0
void MainWindow::on_actionColor_histogram_triggered()
{
    QPixmap pixmap = pixmapItem->pixmap().copy();

    QImage image = pixmap.toImage();
    int width = image.width();
    int height = image.height();

    if (width == 0 || height == 0)
    {
        ui->statusBar->showMessage( tr("Error. Image bad size"), 3000 );
        return;
    }

    int threshold = 180000;
    picturesR.clear();
    QString dirName = QFileDialog::getExistingDirectory(this, tr("Choose directory") );
    QDir dir(dirName);
    QDirIterator it(dir.absolutePath(), QDir::Files);
    std::vector<int> origHist = colHist(pixmap);
    for ( ; it.hasNext(); it.next() )
    {
        QString curFileName = it.filePath();
        QPixmap curPixmap(curFileName);
        if ( curPixmap.isNull() )
            continue;
        std::vector<int> curHist = colHist(curPixmap);
        double dist = histDistance(origHist, curHist);

        if (dist < threshold)
            picturesR.append(curPixmap);
    }

    QString mes = tr("Images: ") + QString::number(picturesR.size());
    ui->statusBar->showMessage(mes, 3000);
    if (picturesR.size() > 0)
    {
        picturesRind = 0;
        pixmapItem_2->setPixmap(picturesR[0]);
        scene_2->setSceneRect(QRectF(picturesR[0].rect()));
    }
}
Exemplo n.º 2
0
double GazeTracker::covariancefunction_hist(vector<int> const& histogram1, vector<int> const& histogram2)
{
    return histDistance(histogram1, histogram2);
}