Ver Mensaje Individual
  #1 (permalink)  
Antiguo 18/07/2011, 04:16
angobar
 
Fecha de Ingreso: julio-2011
Mensajes: 7
Antigüedad: 12 años, 10 meses
Puntos: 0
Violation access in time compilation (0xC0000005)

The process I want to do is to make the FFT to an image (stored in “imagen”) , and then, multiply it with a filter ‘H’, after that, the inverse FFT will be done also.

The code is shown below:

Código:
	int ancho;
	int alto;
	ancho=ui.imageframe->imagereader->GetBufferedRegion().GetSize()[0];		//ancho=widht of the image
	alto=ui.imageframe->imagereader->GetBufferedRegion().GetSize()[1]; 		//alto=height of the image

	double *H ;
	H =matrix2D_H(ancho,alto,eta,sigma); // H is calculated

	// We want to get: F= fft(f) ; H*F ; f'=ifft(H*F)
	// Inicialization of the neccesary elements for the calculation of the fft
	fftw_complex *out;
	fftw_plan p;

	int N= (ancho/2+1)*alto; //number of points of the image
	out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*N);

	double *in = (double*) imagen.GetPointer(); // conversion of itk.smartpointer --> double*
	p = fftw_plan_dft_r2c_2d(ancho, alto, in, out, FFTW_ESTIMATE); // FFT planning
	fftw_execute(p); // FFT calculation

	/* Multiplication of the Output of the FFT with the Filter H*/ 
	int a = alto;
	int b = ancho/2 +1; // The reason for the second dimension to have this value is that when the FFT calculation of a real image is performed only the non-redundants outputs are calculated, that’s the reason for the output of the FFT and the filter ‘H’ to be equal. 

	// Matrix point-by-point multiplicaction: [axb]*[axb]
	fftw_complex* res ; // result will be stored here
	res = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*a*b);
	res = multiply_matrix_2D(out,H, a, b);
The problem is located here, in the loop inside the function ‘multiply_matrix_2D’:
Código:

fftw_complex*  prueba_r01::multiply_matrix_2D(fftw_complex* out, double* H, int M ,int N){
	/* The matrix out[MxN] or [n0x(n1/2)+1] is the image after the FFT , and the out_H[MxN] is the filter in the frequency domain,
	both are multiplied POINT TO POINT, it has to be called  twice, one for the imaginary part and another for the normal part
	*/
	fftw_complex *H_cast;
	H_cast = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*M*N);
	H_cast= reinterpret_cast<fftw_complex*> (H); // casting from double* to fftw_complex*

	fftw_complex *res; // the result of the multiplication will be stored here
	res = (fftw_complex*) fftw_malloc(sizeof(fftw_complex)*M*N);

	//Loop for calculating the matrix point-to-point multiplication
	for (int x = 0; x<M ; x++){
		for (int y = 0; y<N ; y++){
				res[x*N+y][0] = out[x*N+y][0]*(H_cast[x*N+y][0]+H_cast[x*N+y][1]); 
				res[x*N+y][1] = out[x*N+y][1]*(H_cast[x*N+y][0]+H_cast[x*N+y][1]); 
			}
	}
	fftw_free(H_cast);
	return res;
	}

With the values of x = 95 and y = 93 being M = 191 and N = 96;
Uncontroled exception at 0x004273ab in prueba_r01.exe: 0xC0000005 acess infraction reading 0x01274000.




Where a lot of values of the variables are in red, and for translation issue: H_cast[][1] has in the value box : “Error30CXX0000 : impossible to evaluate the expression”.

I will really appreciate any kind of help with this please!!

Antonio