示例#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
void globalStd(PivData *pivData, FilterOptions filterOptions)
{
    double u,v;
    double mxU = 0.0;
    double mxV = 0.0;
    double sxU = 0.0;
    double sxV = 0.0;

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

    double nSigma = filterOptions.nStd();

    // First, compute the global average
    int i, j;
    int count = 0;
    for (i = 0; i < height; i++)
    {
        for (j = 0; j < width; j++)
        {
            if (pivData->isValid(i,j))
            {
                u = pivData->data(i,j).u;
                v = pivData->data(i,j).v;

                mxU += u;
                mxV += v;

                count++;
            }
        }
    }

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

    // Next, compute the standard deviation
    count = 0;
    for (i = 0; i < height; i++)
    {
        for (j = 0; j < width; j++)
        {
            if (pivData->isValid(i,j))
            {
                u = pivData->data(i,j).u;
                v = pivData->data(i,j).v;

                sxU += (u - mxU) * (u - mxU);
                sxV += (v - mxV) * (v - mxV);

                count++;
            }
        }
    }

    if (count > 0)
    {
        sxU = sqrt(sxU / double(count));
        sxV = sqrt(sxV / double(count));
    }
    else
    {
        sxU = 0.0;
        sxV = 0.0;
    }

    /*  Rejecting any point in the PivData where the displacment
        is farther away than nSigma times the global standard deviation
        from the global average.
    */

    for (i = 0; i < height; i++)
    {
        for (j = 0; j < width; j++)
        {
            if (pivData->isValid(i,j))
            {
                u = pivData->data(i,j).u;
                v = pivData->data(i,j).v;

                if (u > (mxU + nSigma*sxU) || u < (mxU - nSigma*sxU) || v > (mxV + nSigma*sxV) || v < (mxV - nSigma*sxV))
                {
                    pivData->setFilter(i,j,true);
                }
            }
        }
    }
}