 	float* d_roi_selectedImage;
 
 	cudaMalloc((void**)&d_roi_selectedImage,ROI_IMAGE_WIDTH*ROI_IMAGE_HEIGHT*sizeof(float));
-	//CudaCheckError();
+	CudaCheckError();
 	
 	cudaMemset(d_roi_selectedImage,0, ROI_IMAGE_HEIGHT*ROI_IMAGE_WIDTH*sizeof(float));
-	//CudaCheckError();
+	CudaCheckError();
 
 	selectROI<<<gridSize,blockSize>>>(d_image, d_roi_selectedImage);
 	cudaDeviceSynchronize();
-	//CudaCheckError();
+	CudaCheckError();
 
 	if(debug_pre_process)
 	{	
 		cudaMemcpy(h_roi_selectedImage,d_roi_selectedImage,sizeof(float)*ROI_IMAGE_HEIGHT*ROI_IMAGE_WIDTH, cudaMemcpyDeviceToHost);
-		//CudaCheckError();
+		CudaCheckError();
 		Mat roi_image(ROI_IMAGE_HEIGHT, ROI_IMAGE_WIDTH, CV_32F);
 		for(int i =0;i<ROI_IMAGE_HEIGHT;i++)
 		{


	gaussian_blur_tiled<<<gridSize,blockSize,smemSize>>>(grayImage,d_filter_Image, IMAGE_HEIGHT, IMAGE_WIDTH,d_kernel, filterWidth);
	cudaDeviceSynchronize();
	//CudaCheckError();
	
	/*
	thrust::device_ptr<float> dbeg(d_filter_Image);
	thrust::device_ptr<float> dend = dbeg + NUMPIX;
	
	float min, max;
	find_min_max(dbeg, dend, &min, &max);
	*/

	cudaMemcpy(h_filter_Image, d_filter_Image, NUMPIX*sizeof(float), cudaMemcpyDeviceToHost);
	unsigned char* bin_image = getQuantile(d_filter_Image, h_filter_Image,0.985);
	

	float* h_filter_Image = (float*)malloc(NUMPIX*sizeof(float));	

	cudaMalloc((void**)&d_kernel,nrow_kernel_y*ncol_kernel_x*sizeof(float));
	CudaCheckError();

	cudaMemcpy(d_kernel,kernel,nrow_kernel_y*ncol_kernel_x*sizeof(float),cudaMemcpyHostToDevice);
	CudaCheckError();

	const int filterWidth = CU_FILTER_WIDTH;

	cudaMalloc((void**)&d_filter_Image, NUMPIX*sizeof(float));
	CudaCheckError();

	const dim3 blockSize(THREAD_X, THREAD_Y);	
	const dim3 gridSize((IMAGE_WIDTH + blockSize.x -1)/blockSize.x, (IMAGE_HEIGHT + blockSize.y -1)/blockSize.y);
