Ejemplo n.º 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()));
}
Ejemplo n.º 2
0
/*---------- Smoothing --------------*/
void gaussianBlur(PivData *pivData, FilterOptions filterOptions)
{
    int width = pivData->width();
    int height = pivData->height();

    int i, j, k, k1, k2;
    double x, y;

    double *uTemp, *vTemp;

    uTemp = new double [width*height + 1];
    vTemp = new double [width*height + 1];

    double radius = filterOptions.smoothRadius();

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

    double *kernel = new double [N*N+1];
    double sumU, sumV;
    PivPointData pointData;

    // Creation of the kernel
    k = 0; x = 0.0;
    for (y = -double(halfN); y <= double(halfN); y = y + 1.0)
    {
        for (x = -double(halfN); x <= double(halfN); x = x + 1.0)
        {
            kernel[k] = 0.5 / pi / radius / radius * exp(-(x*x + y*y) / 2.0 / radius / radius);
            k++;
        }
    }

    // Convolution
    for (i = 0; i < height; i++)
    {
        for (j = 0; j < width; j++)
        {
            sumU = 0.0; sumV = 0.0;
            for (k1 = -halfN; k1 <= halfN; k1++)
            {
                for (k2 = -halfN; k2 <= halfN; k2++)
                {
                    sumU += pivData->data(i-k1,j-k2).u * kernel[(halfN+k1)*N+(halfN+k2)];
                    sumV += pivData->data(i-k1,j-k2).v * kernel[(halfN+k1)*N+(halfN+k2)];
                }
            }
            // Store values to temporary arrays to avoid propogation effects
            uTemp[i*width+j] = sumU;
            vTemp[i*width+j] = sumV;
        }
    }

    // Reassign temporary arrays to original PivData object
    for (i = 0; i < height; i++)
    {
        for (j = 0; j < width; j++)
        {
            pointData = pivData->data(i,j);
            pointData.u = uTemp[i*width+j];
            pointData.v = vTemp[i*width+j];
            pivData->setData(i,j,pointData);
        }
    }

    delete [] kernel;
    delete [] uTemp;
    delete [] vTemp;

}