        y<kernel_radius || y>=W-kernel_radius)
     {
         char temp_value=*(inputData+x+y*H);
-        *(outputMean+x+y*H)=temp_value;
-        *(outputvar+x+y*H)=0;
+        setPixel(outputMean,H,W,x,y,temp_value);
+        setPixel(outputvar,H,W,x,y,0);
     }
     else
     {

        double mean=sum/(kernel_size*kernel_size);
        double var=square_sum/(kernel_size*kernel_size)-mean*mean;
        var=sqrt(var);
        *(outputMean+x+y*H)=mean;
        *(outputvar+x+y*H)=var;
    }
}
__device__ double getPixel(const double *array,int H,int W,int i,int j)
{
    if(i<0 || i>=H || j<0 ||j>=W)
    {
        return 0;
    }
    else
    {
        return *(array+H*j+i);
    }
}
__device__ void setPixel(double *array,int H,int W,int i,int j,double value)
{
    if(i<0 || i>=H || j<0 ||j>=W)
    {
        return;
    }
    *(array+H*j+i)=value;
}

__global__ void intensityFeature(const unsigned char * inputData,double *outputMean,double *outputvar,const int H,const int W,int r)
{
    int x = blockIdx.x * blockDim.x + threadIdx.x;
