Results 1 to 2 of 2

Thread: How to get pixel of image1d_t?

  1. #1

    How to get pixel of image1d_t?

    I tried to work with 1d image in my kernel, but I'm not sure that I know, how the pixels are stored in memory. I created a buffer as follow:
    Code :
    cl_image_desc desc;
        desc.image_type = CL_MEM_OBJECT_IMAGE1D;
        desc.image_width = img.width();
        desc.image_height = img.height();
        desc.image_array_size = 0;
        desc.image_depth = 0;
        desc.image_row_pitch = 0;
        desc.image_slice_pitch = 0;
        desc.num_mip_levels = 0;
        desc.num_samples = 0;
        desc.buffer = nullptr;
     
        cl_mem inputImage = clCreateImage(context,CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR, &format, &desc, img.bits(), &error);

    I supposed that rows of an image are next to each other, so I thought that pixel with coordinates [x,y] is at [y*image_width + x] position in 1d image. So how to read_imagef() pixel of image1d_t in kernel?

  2. #2
    Senior Member
    Join Date
    Dec 2011
    Posts
    237
    You don't access images like memory, you use read_imagef and pass the coordinate of the pixel you want to read. There are many examples online. Why are you talking about "y" for a 1D image? Only "x" applies for 1D. If your height is not 1 then you should use a 2D image.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean