float middle_filter(float middle_value [] , intcount)
創(chuàng)新互聯(lián)建站專注于榆次企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站建設(shè),商城建設(shè)。榆次網(wǎng)站建設(shè)公司,為榆次等地區(qū)提供建站服務(wù)。全流程專業(yè)公司,專業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)建站專業(yè)和態(tài)度為您提供的服務(wù)
{
float sample_value, data;
int i, j;
for (i=1; i for(j=count-1; j=i,--j){
if(middle_value[j-1]=middle_value[j]{
data=middle_value[j-1];
middle_value[j-1]=middle_value[j]
middle_value[j]=data;
}
}
sample_value=middle_value(count-1)/灶喊稿隱孝滲褲2];
return(sample_value);
}
這個(gè)可比你想象晌大的復(fù)雜多了,s是個(gè)復(fù)變量,1/(s+1)極點(diǎn)在-1,要想用C語(yǔ)言寫(xiě),必須理解清楚下面幾個(gè)問(wèn)題:
1、輸入必須是個(gè)有限序列,比如(x+yi),x和y分別是兩個(gè)長(zhǎng)度為N的數(shù)組
2、要過(guò)濾的頻率,必須是個(gè)整型值,或者是個(gè)整型區(qū)間
3、輸出大前結(jié)果同樣是兩個(gè)長(zhǎng)度為N的數(shù)組(p+qi)
4、整個(gè)程宴仿豎序需要使用最基本的復(fù)數(shù)運(yùn)算,這一點(diǎn)C語(yǔ)言本身不提供,必須手工寫(xiě)復(fù)函數(shù)運(yùn)算庫(kù)
5、實(shí)現(xiàn)的時(shí)候具體算法還需要編,這里才是你問(wèn)題的核心。
我可以送你一段FFT的程序,自己琢磨吧,和MATLAB的概念差別很大:
#include assert.h
#include math.h
#include stdio.h
#include stdlib.h
#include string.h
#include windows.h
#include "complex.h"
extern "C" {
// Discrete Fourier Transform (Basic Version, Without Any Enhancement)
// return - Without Special Meaning, constantly, zero
int DFT (long count, CComplex * input, CComplex * output)
{
assert(count);
assert(input);
assert(output);
CComplex F, X, T, W; int n, i;
long N = abs(count); long Inversing = count 0? 1: -1;
for(n = 0; n N ; n++){ // compute from line 0 to N-1
F = CComplex(0.0f, 0.0f); // clear a line
for(i = 0; i N; i++) {
T = input[i];
W = HarmonicPI2(Inversing * n * i, N);
X = T * W;
F += X; // fininshing a line
}//next i
// save data to outpus
memcpy(output + n, F, sizeof(F));
}//next n
return 0;
}//end DFT
int fft (long count, CComplex * input, CComplex * output)
{
assert(count);
assert(input);
assert(output);
int N = abs(count); long Inversing = count 0? -1: 1;
if (N % 2 || N 5) return DFT(count, input, output);
long N2 = N / 2;
CComplex * iEven = new CComplex[N2]; memset(iEven, 0, sizeof(CComplex) * N2);
CComplex * oEven = new CComplex[N2]; memset(oEven, 0, sizeof(CComplex) * N2);
CComplex * iOdd = new CComplex[N2]; memset(iOdd , 0, sizeof(CComplex) * N2);
CComplex * oOdd = new CComplex[N2]; memset(oOdd , 0, sizeof(CComplex) * N2);
int i = 0; CComplex W;
for(i = 0; i N2; i++) {
iEven[i] = input[i * 2];
iOdd [i] = input[i * 2 + 1];
}//next i
fft(N2 * Inversing, iEven, oEven);
fft(N2 * Inversing, iOdd, oOdd );
for(i = 0; i N2; i++) {
W = HarmonicPI2(Inversing * (- i), N);
output[i] = oEven[i] + W * oOdd[i];
output[i + N2] = oEven[i] - W * oOdd[i];
}//next i
return 0;
}//end FFT
void __stdcall FFT(
long N, // Serial Length, N 0 for DFT, N 0 for iDFT - inversed Discrete Fourier Transform
double * inputReal, double * inputImaginary, // inputs
double * AmplitudeFrequences, double * PhaseFrequences) // outputs
{
if (N == 0) return;
if (!inputReal !inputImaginary) return;
short n = abs(N);
CComplex * input = new CComplex[n]; memset(input, 0, sizeof(CComplex) * n);
CComplex * output= new CComplex[n]; memset(output,0, sizeof(CComplex) * n);
double rl = 0.0f, im = 0.0f; int i = 0;
for (i = 0; i n; i++) {
rl = 0.0f; im = 0.0f;
if (inputReal) rl = inputReal[i];
if (inputImaginary) im = inputImaginary[i];
input[i] = CComplex(rl, im);
}//next i
int f = fft(N, input, output);
double factor = n;
//factor = sqrt(factor);
if (N 0)
factor = 1.0f;
else
factor = 1.0f / factor;
//end if
for (i = 0; i n; i++) {
if (AmplitudeFrequences) AmplitudeFrequences[i] = output[i].getReal() * factor;
if (PhaseFrequences) PhaseFrequences[i] = output[i].getImaginary() * factor;
}//next i
delete [] output;
delete [] input;
return ;
}//end FFT
int __cdecl main(int argc, char * argv[])
{
fprintf(stderr, "%s usage:\n", argv[0]);
fprintf(stderr, "Public Declare Sub FFT Lib \"wfft.exe\" \
(ByVal N As Long, ByRef inputReal As Double, ByRef inputImaginary As Double, \
ByRef freqAmplitude As Double, ByRef freqPhase As Double)");
return 0;
}//end main
};//end extern "C"
1. 是規(guī)定做中值濾波的早族點(diǎn)不含邊緣塌睜游的點(diǎn)(取決于中值濾波窗口大團(tuán)銷小)。 2,對(duì)圖像邊緣部分的信息進(jìn)行鏡像處理。
分享題目:濾波器函數(shù)c語(yǔ)言 c 濾波器
瀏覽地址:http://vcdvsql.cn/article26/ddpedcg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、網(wǎng)站維護(hù)、虛擬主機(jī)、響應(yīng)式網(wǎng)站、企業(yè)網(wǎng)站制作、品牌網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容