Foros del Web » Programación para mayores de 30 ;) » C/C++ »

Violation access in time compilation (0xC0000005)

Estas en el tema de Violation access in time compilation (0xC0000005) en el foro de C/C++ en Foros del Web. The process I want to do is to make the FFT to an image (stored in “imagen”) , and then, multiply it with a filter ...
  #1 (permalink)  
Antiguo 18/07/2011, 04:16
 
Fecha de Ingreso: julio-2011
Mensajes: 7
Antigüedad: 12 años, 9 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
  #2 (permalink)  
Antiguo 18/07/2011, 09:58
 
Fecha de Ingreso: junio-2008
Ubicación: Seattle, USA
Mensajes: 733
Antigüedad: 15 años, 10 meses
Puntos: 61
Respuesta: Violation access in time compilation (0xC0000005)

respuesta = "Sospecho que tu arreglo de double H no tiene tantos fftw_complex como supones.
reinterpret_cast es permisivo y te hace ver una cosa por otra, pero no creará mas memoria que la que efectivamente tienes."


answer = translate( answer, "english" )

Última edición por CalgaryCorpus; 18/07/2011 a las 10:45

Etiquetas: access, c++, itk, violation
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 01:28.