 	getParam("blockZ", blockZ, argc, argv);
 	cout << "blocksize: " << blockX << "x" << blockY << "x" << blockZ << endl;
 
-    float theta = 50.0f;
+    int width = 640;
+    getParam("width", width, argc, argv);
+    cout << "width: " << width << endl;
+
+    int height = 480;
+    getParam("height", height, argc, argv);
+    cout << "height: " << height << endl;
+
+    float theta = 100.0f;
     getParam("theta", theta, argc, argv);
     cout << "theta: " << theta << endl;
 
-    float tau = 0.02f;
+    float tau = 0.005f;
     getParam("tau", tau, argc, argv);
     cout << "tau: " << tau << endl;
 
-    float decay = 0.98f;
+    float decay = 0.975f;
     getParam("decay", decay, argc, argv);
     cout << "decay: " << decay << endl;
 
-    int N1 = 1;
-    getParam("N1", N1, argc, argv);
-    cout << "N1: " << N1 << endl;
-
-    int N2 = 1;
-    getParam("N2", N2, argc, argv);
-    cout << "N2: " << N2 << endl;
+    int N = 2500;
+    getParam("N", N, argc, argv);
+    cout << "N: " << N << endl;
 
 #ifdef KINECT
 // Codes to read from Kinect
 
 #else
     // Load the raw file (Size must be 640x480 == IMG_WIDTH*IMG_HEIGHT)
-	uint16_t *depth = new uint16_t[IMG_WIDTH*IMG_HEIGHT];
+	uint16_t *depth = new uint16_t[width*height];
 	ifstream file_buf(rawfile.c_str(), ios_base::binary);
-	file_buf.read((char*) depth, IMG_WIDTH*IMG_HEIGHT*sizeof(uint64_t));
+	file_buf.read((char*) depth, width*height*sizeof(uint64_t));
     file_buf.close();
 
 	// Find Maximum and convert it to float
-	float *fInDepth = new float[IMG_WIDTH*IMG_HEIGHT];
+	float *fInDepth = new float[width*height];
 	uint16_t maxValue = 0;
-	for (size_t y = 0; y < IMG_HEIGHT; y++)
-    {
-        size_t offset = y*IMG_WIDTH;
-		for (size_t x = 0; x < IMG_WIDTH; x++)
+	for (int y = 0; y < height; y++)
+    {
+        size_t offset = (size_t)y*width;
+		for (int x = 0; x < width; x++)
 			if (maxValue < depth[x + offset]) maxValue = depth[x + offset];
     }
 
     // Normalize the input data
-	for (size_t y = 0; y < IMG_HEIGHT; y++)
-    {
-        size_t offset = y*IMG_WIDTH;
-		for (size_t x = 0; x < IMG_WIDTH; x++)
+	for (int y = 0; y < height; y++)
+    {
+        size_t offset = (size_t)y*width;
+		for (int x = 0; x < width; x++)
 			fInDepth[x + offset] = (float)depth[x + offset] / (float)maxValue;
     }
 
     // Setup input image
-	cv::Mat mInDepth(IMG_HEIGHT,IMG_WIDTH,CV_32FC1);
+	cv::Mat mInDepth(height,width,CV_32FC1);
 	convert_layered_to_mat(mInDepth, (const float*) fInDepth);
 
     // Setup output image
-    float *fOutDepth = new float[(size_t)IMG_WIDTH*IMG_HEIGHT];
-	cv::Mat mOutDepth(IMG_HEIGHT,IMG_WIDTH,CV_32FC1);
+    float *fOutDepth = new float[(size_t)width*height];
+	cv::Mat mOutDepth(height,width,CV_32FC1);
     
 #endif
 


// Uncomment to use the live Kinect Camera
//#define KINECT
#define IMG_WIDTH 640
#define IMG_HEIGHT 480

__global__ void DiamondDotProduct(float *p, float *d, int w, int h)
{


        float pp = p[idx];
        float a1 = 0.0f;    float a2 = 0.0f;    float a3 = 0.0f;
        float b1 = 0.0f;    float b2 = 0.0f;    float b3 = 0.0f;
        float c1 = 0.0f;    float c2 = 0.0f;    float c3 = 0.0f;
        float d1 = 0.0f;    float d2 = 0.0f;    float d3 = 0.0f;
                                                float e3 = 0.0f;

        if(x!=0)            { a1 = p[idx-1]; a2 = p[idx+(size_t)h*w-1]; a3 = p[idx+(size_t)2*h*w-1]; }
        if((x+1)!=w)        { b1 = p[idx+1]; b2 = p[idx+(size_t)h*w+1]; b3 = p[idx+(size_t)2*h*w+1]; }
        if(y!=0)            { c1 = p[idx-w]; c2 = p[idx+(size_t)h*w-w]; c3 = p[idx+(size_t)2*h*w-w]; }
        if((y+1)!=h)        { d1 = p[idx+w]; d2 = p[idx+(size_t)h*w+w]; d3 = p[idx+(size_t)2*h*w+w]; }
        if(y!=0 && x!=0)    {                                           e3  = p[idx+(size_t)2*h*w-w-1]; }
        //if((y+1)!=h && (x+1)!=h)    {                                   e3  = p[idx+(size_t)2*h*w+w+1]; }

