 void readImage(char* filename,im_type* imread, int32_t rows, int32_t cols)
 {
 	FILE* file=fopen(filename,"r");
-	im_type temp;
+	int32_t temp;
 	for(int32_t r=0; r<rows;r++){
 		for(int32_t c=0; c<cols; c++){
-			fscanf(file, "%d ", &temp);
-			imread[r*cols+c]=temp;
+			int read=fscanf(file, "%d ", &temp);
+			im_type stam=temp;
+			imread[r*cols+c]=(im_type)stam;
 		}
 	}
 

}


__device__ void historgramMedian(hist_type* H, const int32_t size, const int32_t medPos, int32_t* retval){
	int32_t tx=threadIdx.x;
	if(tx==0){
		int32_t sum=0;
		*retval=size;
		for(int32_t i=0; i<size; i++){
			sum+=H[i];
			if(sum>=medPos){
				*retval=i;
				return;
			}
		}

	}
}

__device__ void ClearDest(im_type* dest,int32_t rows,int32_t cols){
	int32_t tx=threadIdx.x;
	int32_t totalPixels=rows*cols;
	for(; tx<totalPixels;tx+=blockDim.x)
		dest[tx]=0;
}

/////////////////////////////////////////
/////////////////////////////////////////

#include <stdio.h>
#include <inttypes.h>


#define TEST
// THREADS is defined to be the max threads
#define MAX_THREADS 256
