高斯滤波(低通滤波)在Origin里面能不能做 或者excel里面能不能做,求教!
发布网友
发布时间:2022-04-30 20:01
我来回答
共1个回答
热心网友
时间:2023-10-09 23:46
int cuBandLimitPro(unsigned short* pSrc, unsigned short* pDst){
cuFloatComplex* hSrc;
cuFloatComplex* hDst;
cuFloatComplex* dData;
cufftHandle plan;
float temp;
int imgSize = imgWidth * imgHeight;
hSrc = (cuFloatComplex*)malloc(sizeof(cuFloatComplex) * imgSize);
hDst = (cuFloatComplex*)malloc(sizeof(cuFloatComplex) * imgSize);
cudaMalloc((void**) &dData, sizeof(cuFloatComplex) * imgSize);
cufftPlan2d(&plan, imgWidth, imgHeight, CUFFT_C2C);
for(int i = 0; i < imgSize; i ++)
hSrc[i].x = pSrc[i];
cudaMemcpy(dData, hSrc, sizeof(cuFloatComplex) * imgSize, cudaMemcpyHostToDevice);
// FFT
cufftExecC2C(plan, (cuFloatComplex*)dData, (cuFloatComplex*)dData, CUFFT_FORWARD);
// Band-Stop Filter
// 这里按需求随便写点带阻、带通的东西。
// iFFT
cufftExecC2C(plan, (cuFloatComplex*)dData, (cuFloatComplex*)dData, CUFFT_INVERSE);
cudaMemcpy(hDst, dData, sizeof(cuFloatComplex) * imgSize, cudaMemcpyDeviceToHost);
for(int i = 0; i < imgSize; i ++){
temp = hDst[i].x / imgSize / 4;
//temp = pFFTR[i][0] / 2;
if(temp < 0)
pDst[i] = 0;
else if(temp > cuBLMaxValue)
pDst[i] = cuBLMaxValue;
else
pDst[i] = (unsigned short)(temp + 0.5f);
}
cudaFree(dData);
free(hSrc);
free(hDst);
return 1;
}