Results 1 to 4 of 4

Thread: 16bits per channel RGB Image

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Posts
    1

    16bits per channel RGB Image

    Hello,

    I'm trying to process Image in OpenCl...

    Only problem : my Images are 16-bits per channel images...

    Is there anyone that has an idea or an example...of let's say an opencl example which from an unsigned short * which contains the pixels values ( unsigned short Tab_Pixels[W*H*3]) ) and proceeds it in an program...to for example add some contrast...

    Thanks if anyone can put some light in there

  2. #2
    Senior Member
    Join Date
    Nov 2009
    Posts
    118

    Re: 16bits per channel RGB Image

    An example of AMD for image convolution :
    http://developer.amd.com/GPU/ATISTREAMS ... penCL.aspx

    It does not use unsigned short *, but anyway in OpenCL 1.0 (not in 1.1) you can't write in an unsigned short buffer without the "Byte adressable store" extension. So perhaps you'll have to put them as integer.

  3. #3
    Junior Member
    Join Date
    Apr 2010
    Posts
    26

    Re: 16bits per channel RGB Image

    Quote Originally Posted by sapym
    Only problem : my Images are 16-bits per channel images...

    Is there anyone that has an idea or an example...of let's say an opencl example which from an unsigned short * which contains the pixels values ( unsigned short Tab_Pixels[W*H*3]) ) and proceeds it in an program...to for example add some contrast...
    Does section 5.2.4.1 of the 1.0 Specification Revision 48, "Image Format Descriptor," help you?

    Host Code:
    If you have an image, you should also have a image format descriptor.
    Set the image_channel_data_type to be CL_UNSIGNED_INT16, inside this descriptor.

    Code :
    cl_image_format img2Dformat = {CL_RGBA, CL_UNSIGNED_INT16};

    Copy this image to the GPU.

    Kernel Code:
    The pixel/texel you're reading inside the image can then be read into an appropriate data type inside the kernel.

    I imagine something like this should do the trick:
    Code :
    sampler_t sampler = CLK_NORMALIZED_COORDS_FALSE | CLK_ADDRESS_NONE | CLK_FILTER_NEAREST;
     
    ushort4 myPixel;
    int2 coord;
     
    coord[0] = i; // width index
    coord[1] = j; // height index
     
    myPixel = read_image(pInImage, sampler, coord);

    Each pixel will then have 4 values corresponding to each image channel (RGBA etc...).

  4. #4
    Senior Member
    Join Date
    Sep 2002
    Location
    Santa Clara
    Posts
    105

    Re: 16bits per channel RGB Image

    If you have a 16-bit / channel RGBA image and want to process these pixel values as floating-point values in your OpenCL kernel then create the image with

    cl_image_format image_format;

    image_format.image_channel_order = CL_RGBA
    image_format.image_channel_data_type = CL_UNORM_INT16

    In your CL kernel, you call read_imagef to read from this image. The implementation will read 16-bit/channel pixel values and convert them to float. Similarly write_imagef will take a float4 color value and convert them to the appropriate channel format which in this case will be 16-bits/channel.

    If you want to read the data as integer values instead then

    image_format.image_channel_data_type = CL_UNSIGNED_INT16 or CL_SIGNED_INT16 depending on whether the data you want to read is an unsigned or signed 16-bit integer.

    In the CL kernel you call read_imageui or read_imagei which will return a 4-component integer vector. Similarly write_imageui or write_imagei will take a 4-component integer vector and convert them to the appropriate channel format.

Similar Threads

  1. RGB image in RGBA format
    By wscrosswy in forum OpenCL
    Replies: 3
    Last Post: 06-08-2011, 08:58 AM
  2. No image format 24 bit RGB?
    By user42 in forum OpenVG and VGU
    Replies: 1
    Last Post: 09-16-2008, 12:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •