fixed syntax error in 3d image gradient kernel

__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;

#ifdef TYPE_UINT
#define READ_IMAGE (float)read_imageui
#elif TYPE_INT
#define READ_IMAGE (float)read_imagei
#elif TYPE_FLOAT
#define READ_IMAGE read_imagef
#endif

__kernel void gradient2D(
        __read_only image2d_t input,
        __write_only image2d_t output
        ) {
    const int2 pos = {get_global_id(0), get_global_id(1)};

    // TODO take pixel spacing into account
    float4 gradient = {
            (READ_IMAGE(input, sampler, pos+(int2)(1,0)).x - READ_IMAGE(input, sampler, pos-(int2)(1,0)).x)/2.0f,
            (READ_IMAGE(input, sampler, pos+(int2)(0,1)).x - READ_IMAGE(input, sampler, pos-(int2)(0,1)).x)/2.0f,
            0,0
    };
    write_imagef(output, pos, gradient);
}

__kernel void gradient3D(
        __read_only image3d_t input,
#ifdef cl_khr_3d_image_writes
        __write_only image3d_t output
#else
        __global float* output
#endif
        ) {
    const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};

    // TODO take pixel spacing into account
    float4 gradient = {
            (READ_IMAGE(input, sampler, pos+(int4)(1,0,0,0)).x - READ_IMAGE(input, sampler, pos-(int4)(1,0,0,0)).x)*0.5f,
            (READ_IMAGE(input, sampler, pos+(int4)(0,1,0,0)).x - READ_IMAGE(input, sampler, pos-(int4)(0,1,0,0)).x)*0.5f,
            (READ_IMAGE(input, sampler, pos+(int4)(0,0,1,0)).x - READ_IMAGE(input, sampler, pos-(int4)(0,0,1,0)).x)*0.5f,
            0
    };
#ifdef cl_khr_3d_image_writes
    write_imagef(output, pos, gradient);
#else
    vstore3(gradient, pos.x+pos.y*get_global_size(0)+pos.z*get_global_size(0)*get_global_size(1), output);
#endif
}

__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;

#ifdef TYPE_UINT
#define READ_IMAGE (float)read_imageui
#elif TYPE_INT
#define READ_IMAGE (float)read_imagei
#elif TYPE_FLOAT
#define READ_IMAGE read_imagef
#endif

__kernel void gradient2D(
        __read_only image2d_t input,
        __write_only image2d_t output
        ) {
    const int2 pos = {get_global_id(0), get_global_id(1)};

    // TODO take pixel spacing into account
    float4 gradient = {
            (READ_IMAGE(input, sampler, pos+(int2)(1,0)).x - READ_IMAGE(input, sampler, pos-(int2)(1,0)).x)/2.0f,
            (READ_IMAGE(input, sampler, pos+(int2)(0,1)).x - READ_IMAGE(input, sampler, pos-(int2)(0,1)).x)/2.0f,
            0,0
    };
    write_imagef(output, pos, gradient);
}

__kernel void gradient3D(
        __read_only image3d_t input,
#ifdef cl_khr_3d_image_writes
        __write_only image3d_t output
#else
        __global float* output
#endif
        ) {
    const int4 pos = {get_global_id(0), get_global_id(1), get_global_id(2), 0};

    // TODO take pixel spacing into account
    float4 gradient = {
            (READ_IMAGE(input, sampler, pos+(int4)(1,0,0,0)).x - READ_IMAGE(input, sampler, pos-(int4)(1,0,0,0)).x)*0.5f,
            (READ_IMAGE(input, sampler, pos+(int4)(0,1,0,0)).x - READ_IMAGE(input, sampler, pos-(int4)(0,1,0,0)).x)*0.5f,
            (READ_IMAGE(input, sampler, pos+(int4)(0,0,1,0)).x - READ_IMAGE(input, sampler, pos-(int4)(0,0,1,0)).x)*0.5f,
            0
    };
#ifdef cl_khr_3d_image_writes
    write_imagef(output, pos, gradient);
#else
    vstore3(gradient, pos.x()+pos.y()*get_global_size(0)+pos.z()*get_global_size(0)*get_global_size(1), output);
#endif
}


possible to have color in image renderer

__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;

__kernel void renderToTextureFloat(
        __read_only image2d_t image,
        __write_only image2d_t texture,
        __private float level,
        __private float window
        ) {
    const int x = get_global_id(0);
    const int y = get_global_id(1);

    float4 value = read_imagef(image, sampler, (int2)(x,y));
    if(get_image_channel_order(image) == CLK_R) {
        value.y = value.x;
        value.z = value.x;
    }

    value = (value - level + window/2) / window;
    value = clamp(value, 0.0f, 1.0f);
    write_imagef(texture, (int2)(x,get_global_size(1)-y-1), value);
}

__kernel void renderToTextureUint(
        __read_only image2d_t image,
        __write_only image2d_t texture,
        __private float level,
        __private float window
        ) {
    const int x = get_global_id(0);
    const int y = get_global_id(1);

    float4 value = convert_float4(read_imageui(image, sampler, (int2)(x,y)));
    if(get_image_channel_order(image) == CLK_R) {
        value.y = value.x;
        value.z = value.x;
    }

    value = (value - level + window/2) / window;
    value = clamp(value, 0.0f, 1.0f);
    write_imagef(texture, (int2)(x,get_global_size(1)-y-1), value);
}

__kernel void renderToTextureInt(
        __read_only image2d_t image,
        __write_only image2d_t texture,
        __private float level,
        __private float window
        ) {
    const int x = get_global_id(0);
    const int y = get_global_id(1);

    float4 value = convert_float4(read_imagei(image, sampler, (int2)(x,y)));
    if(get_image_channel_order(image) == CLK_R) {
        value.y = value.x;
        value.z = value.x;
    }

    value = (value - level + window/2) / window;
    value = clamp(value, 0.0f, 1.0f);
    write_imagef(texture, (int2)(x,get_global_size(1)-y-1), value);
}

__constant sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_CLAMP | CLK_FILTER_NEAREST;

__kernel void renderToTextureFloat(
        __read_only image2d_t image,
        __write_only image2d_t texture,
        __private float level,
        __private float window
        ) {
    const int x = get_global_id(0);
    const int y = get_global_id(1);

    // TODO components support
    float value = read_imagef(image, sampler, (int2)(x,y)).x;

    value = (value - level + window/2) / window;
    value = clamp(value, 0.0f, 1.0f);
    write_imagef(texture, (int2)(x,get_global_size(1)-y-1), (float4)(value,value,value,1.0));
}

__kernel void renderToTextureUint(
        __read_only image2d_t image,
        __write_only image2d_t texture,
        __private float level,
        __private float window
        ) {
    const int x = get_global_id(0);
    const int y = get_global_id(1);

    // TODO components support
    float value = (float)read_imageui(image, sampler, (int2)(x,y)).x;

    value = (value - level + window/2) / window;
    value = clamp(value, 0.0f, 1.0f);
    write_imagef(texture, (int2)(x,get_global_size(1)-y-1), (float4)(value,value,value,1.0));
}

__kernel void renderToTextureInt(
        __read_only image2d_t image,
        __write_only image2d_t texture,
        __private float level,
        __private float window
        ) {
    const int x = get_global_id(0);
    const int y = get_global_id(1);

    // TODO components support
    float value = (float)read_imagei(image, sampler, (int2)(x,y)).x;

    value = (value - level + window/2) / window;
    value = clamp(value, 0.0f, 1.0f);
    write_imagef(texture, (int2)(x,get_global_size(1)-y-1), (float4)(value,value,value,1.0));
}