void FBlurShader::ComputeBlurSamples(int sampleCount, float blurAmount, TArray<float> &sampleWeights, TArray<int> &sampleOffsets) { sampleWeights.Resize(sampleCount); sampleOffsets.Resize(sampleCount); sampleWeights[0] = ComputeGaussian(0, blurAmount); sampleOffsets[0] = 0; float totalWeights = sampleWeights[0]; for (int i = 0; i < sampleCount / 2; i++) { float weight = ComputeGaussian(i + 1.0f, blurAmount); sampleWeights[i * 2 + 1] = weight; sampleWeights[i * 2 + 2] = weight; sampleOffsets[i * 2 + 1] = i + 1; sampleOffsets[i * 2 + 2] = -i - 1; totalWeights += weight * 2; } for (int i = 0; i < sampleCount; i++) { sampleWeights[i] /= totalWeights; } }
//---------------------------------------- double CBratAlgoFilterGaussian1D::Run(CVectorBratAlgorithmParam& args) { int32_t iRecord = m_callerProduct->GetCurrentRecordNumber(); if (iRecord == m_callerProductRecordPrev) { // Do nothing: data have been already computed return m_gaussian; } setDefaultValue(m_gaussian); OpenProductFile(); // Gets the next record regarding to the current product record. // and save previous values. //this->GetNextData(); // Get current parameter values (included expression value) SetParamValues(args); //// Set only the first value, others values will be stored in the 'SetNextValues' //if (m_rawDataWindow.size() <= 0) //{ // m_rawDataWindow.Insert(m_varValue); //} if (m_dataWindowLength > static_cast<uint32_t>(m_nProductRecords)) { throw CAlgorithmException(CTools::Format("'%s' algorithm can't be applied because the window size parameter (%d) is greater than the number of data values (%d) within the data file (%s). " "You have to decrease the window size parameter", this->GetName().c_str(), m_dataWindowLength, m_nProductRecords, m_currentFileName.c_str()), this->GetName(), BRATHL_LOGIC_ERROR); } if (m_dataWindowLength < 1) { PrepareReturn(); return m_gaussian; } if (m_dataWindowLength == 1) { m_gaussian = m_varValue; PrepareReturn(); return m_varValue; } // If 'default value' and no extrapolation then returns if (isDefaultValue(m_varValue) && (m_extrapolate == 0)) { PrepareReturn(); return m_gaussian; } uint32_t shiftSymmetry = 1; PrepareDataValues1D(shiftSymmetry); ComputeGaussian(); PrepareReturn(); return m_gaussian; }