コード例 #1
0
void MainWindow::setFilterTab()
{
    FilterOptions filterOptions = settings->filterOptions();

    // Global
    minUedit->setText(QString("%1").arg(filterOptions.umin()));
    maxUedit->setText(QString("%1").arg(filterOptions.umax()));
    minVedit->setText(QString("%1").arg(filterOptions.vmin()));
    maxVedit->setText(QString("%1").arg(filterOptions.vmax()));

    minUedit->setEnabled(filterOptions.globalRange());
    maxUedit->setEnabled(filterOptions.globalRange());
    minVedit->setEnabled(filterOptions.globalRange());
    maxVedit->setEnabled(filterOptions.globalRange());

    nStdDevSpin->setValue(filterOptions.nStd());
    nStdDevSpin->setEnabled(filterOptions.globalStd());

    // Local
    localMethodCombo->setEnabled(filterOptions.local());
    localMethodCombo->setCurrentIndex(filterOptions.localMethod());
    localNxNCombo->setEnabled(filterOptions.local());
    localNxNCombo->setCurrentIndex((filterOptions.localNxN()-1)/2-1);
    localUedit->setEnabled(filterOptions.local());
    localVedit->setEnabled(filterOptions.local());
    localUedit->setText(QString("%1").arg(filterOptions.uTol()));
    localVedit->setText(QString("%1").arg(filterOptions.vTol()));

    // Interpolate
    interpolateMethodCombo->setEnabled(filterOptions.interpolate());
    interpolateMethodCombo->setCurrentIndex(filterOptions.intMethod());
    interpolateNxNCombo->setEnabled(filterOptions.interpolate());
    interpolateNxNCombo->setCurrentIndex((filterOptions.intNxN()-1)/2-1);

    // Smoothing
    smoothNxNCombo->setEnabled(filterOptions.smoothing());
    smoothNxNCombo->setCurrentIndex((filterOptions.smoothNxN()-1)/2-1);
    smoothRadiusEdit->setEnabled(filterOptions.smoothing());
    smoothRadiusEdit->setText(QString("%1").arg(filterOptions.smoothRadius()));
}
コード例 #2
0
ファイル: filters.cpp プロジェクト: 7islands/openpiv-c--qt
/*------------Local-------------------*/
void localDetect(PivData *pivData, FilterOptions filterOptions)
{
    double u, v;

    int width = pivData->width();
    int height = pivData->height();

    int i, j, m, n, count;

    int N = filterOptions.localNxN();
    int halfN = floor(double(N - 1) / 2.0);

    double uTol = filterOptions.uTol();
    double vTol = filterOptions.vTol();

    // First need to calculate the central estimator of the local neighbourhood
    switch(filterOptions.localMethod())
    {
    // Calculation of the local mean
    case OpenPIV::LocalMean:
        double mxU, mxV;
        for (i = 0; i < height; i++)
        {
            for (j = 0; j < width; j++)
            {
                u = pivData->data(i,j).u;
                v = pivData->data(i,j).v;

                mxU = 0.0; mxV = 0.0; count = 0;
                for (m = -halfN; m <= halfN; m++)
                {
                    for (n = -halfN; n <= halfN; n++)
                    {
                        if (!pivData->filtered(i+m,j+n))
                        {
                            mxU += pivData->data(i+m,j+n).u;
                            mxV += pivData->data(i+m,j+n).v;
                            count++;
                        }
                    }
                }

                if (count > 0)
                {
                    mxU = mxU / double(count);
                    mxV = mxV / double(count);
                }
                else
                {
                    mxU = 0.0;
                    mxV = 0.0;
                }

                /*  Rejecting any point in the PivData where the displacment
                    exceeds the tolerance of the local mean.
                */
                if (u > (mxU + uTol) || u < (mxU - uTol) || v > (mxV + vTol) || v < (mxV - vTol))
                {
                    pivData->setFilter(i,j,true);
                }

            }
        }
        break;

    // Calculation of the local median
    case OpenPIV::LocalMedian:
        double medU, medV;
        QList<double> listU;
        QList<double> listV;
        for (i = 0; i < height; i++)
        {
            for (j = 0; j < width; j++)
            {
                u = pivData->data(i,j).u;
                v = pivData->data(i,j).v;

                listU.clear();
                listV.clear();
                for (m = -halfN; m <= halfN; m++)
                {
                    for (n = -halfN; n <= halfN; n++)
                    {
                        if (!pivData->filtered(i+m,j+n))
                        {
                            listU << pivData->data(i+m,j+n).u;
                            listV << pivData->data(i+m,j+n).v;
                        }
                    }
                }
                qSort(listU.begin(), listU.end());
                qSort(listV.begin(), listV.end());

                medU = listU.value(int(ceil(double(listU.size())/2.0)));
                medV = listV.value(int(ceil(double(listV.size())/2.0)));

                /*  Rejecting any point in the PivData where the displacment
                    exceeds the tolerance of the local median.
                */
                if (u > (medU + uTol) || u < (medU - uTol) || v > (medV + vTol) || v < (medV - vTol))
                {
                    pivData->setFilter(i,j,true);
                }
            }
        }
        break;
    }

}