             factor_sum2 += val[i]*weight_sum0;
         }
 
-        //Process first 4 pixels
-        /*xval     = _mm_load_ps(val);
-        //Subtract the first 4 pixels from the current
-        xweight1 = _mm_sub_ps(xval,_mm_set1_ps(val_curr));
-        //Apply mask with bitwise and function
-        // (xabsmask = 0x7FFFFFFF or all 1's  except for sign bit) thus acts as absolute value
-        //Mask UNSAFE use alternative
-        //xweight1 = _mm_and_ps(xweight1,xabsmask);
-        xweight1 = _mm_max_ps(_mm_sub_ps(_mm_setzero_ps(), xweight1), xweight1);
-        //4-weight1
-        xweight1 = _mm_sub_ps(xconst4,xweight1);
-        //Finds max of 2 values, if xweight1 is negative return 0
-        xweight1 = _mm_max_ps(xconst0,xweight1);
-        //currect val*xweight = our factor
-        xfactor1 = _mm_mul_ps(xval,xweight1);
-
-        //Process next 4 pixels
-        xval     = _mm_load_ps(val+4);      
-        xweight2 = _mm_sub_ps(xval,_mm_set1_ps(val_curr));
-        //Mask UNSAFE use alternative
-        //xweight2 = _mm_and_ps(xweight2,xabsmask);
-        xweight2 = _mm_max_ps(_mm_sub_ps(_mm_setzero_ps(), xweight2), xweight2);
-        xweight2 = _mm_sub_ps(xconst4,xweight2);
-        xweight2 = _mm_max_ps(xconst0,xweight2);
-        xfactor2 = _mm_mul_ps(xval,xweight2);
-
-        //sum up factor and weight
-        xweight1 = _mm_add_ps(xweight1,xweight2);
-        xfactor1 = _mm_add_ps(xfactor1,xfactor2);
-
-        //Pull out factor and weight from vector registers
-        _mm_store_ps(weight,xweight1);
-        _mm_store_ps(factor,xfactor1);
-
-        //Sum it up
-        float weight_sum = weight[0]+weight[1]+weight[2]+weight[3];
-        float factor_sum = factor[0]+factor[1]+factor[2]+factor[3];*/
-
         if (weight_sum2>0) {
           float d = factor_sum2/weight_sum2;
           if (d>=0) *(D_tmp+v*D_width+(u-3)) = d;

  } else {
    
    // Calculate size of kernel
    /*int block_width = 8;
    int block_height = block_width;
    int grid_width, grid_height;


            factor_sum2 += val[i]*weight_sum0;
        }

        if (weight_sum2>0) {
          float d = factor_sum2/weight_sum2;
          if (d>=0) *(D+(v-3)*D_width+u) = d;
        }
      }
    }*/
  }
  
  // free memory
