要制作一个二维除噪的程序
遇到了下面的问题,希望得到解决
中间有省略
int main()
{
float dt, dx, h, c, x, t, win[N] = { 0.1,0.2,0.4,0.2,0.1 };
int nt, nx, nv, iv, it, ix, N2 = N / 2;
float **data = NULL;
float **denoised;
float *w;
w = read_1Dfloat("ricker.txt", &nv);
data = malloc_2D(nx, nt);
denoised = malloc_2D(nx, nt);
for (ix = 0; ix < nx; ix++)
{
x = ix * dx;
t = sqrt(x*x + 4 * h*h) / c;
it = (int)(t / dt + 0.5);
for (iv = 0; iv < nv; iv++)
data[ix][it + iv] = w[iv];
}
for (ix = 0; ix < nx; ix++)
{
float *noise;
noise = randnoise(nt, 0.1);
for (it = 0; it < nt; it++)
data[ix][it] += noise[it];
free(noise);
}
write_2Dfloatbin("prestack_noise.bin", data, nx, nt);
free(w);
for (ix = 0; ix < nx; ix++)
for (it = 0; it < N2; it++)
denoised[ix][it] = data[ix][it];
for (ix = 0; ix < nx; ix++)
for (it = nt - N2; it < nt; it++)
denoised[ix][it] = data[ix][it];
float *us = NULL;
us = (float *)malloc(sizeof(float) * nt);
for (it = 0; it < nt; it++)
us[it] = 0.;
complex *tmp;
for (ix = 0; ix < nx; ix++)
{
for (it = 0; it < nt; it++)
us[it] = data[ix][it];
tmp = conv(us, nt, win, N); 该行有问题
for (it = N2; it < nt - N2; it++)
{
denoised[ix][it] = tmp[it - N2 + N - 1];
}
}
write_2Dfloatbin("prestack_denoised", denoised, nx, nt);
free(us);
free(data);
free(denoised);
return 0;
}
float *conv(float *x, int nx, float *h, int nh)
{
float *y = NULL;
int ny = nx + nh - 1, iy, ix;
y = (float *)malloc(sizeof(float)*ny);
for (iy = 0; iy < ny; iy++)
y[iy] = 0.;
for (iy = 0; iy < ny; iy++)
{
for (ix = 0; ix < nx; ix++)
{
if (iy - ix >= 0 && iy - ix < nh)
y[iy] += x[ix] * h[iy - ix];
}
}
return y;
}
error C2440: '=' : cannot convert from 'float *' to 'struct comp *'
error C2679: binary '=' : no operator defined which takes a right-hand operand of type 'struct comp' (or there is no acceptable conversion)