Results 1 to 9 of 9

Thread: opencl, images,samplers and interpolation

  1. #1

    opencl, images,samplers and interpolation

    hello.
    I'm studing opencl, in particular image processing.
    is possible to create a sampler that interpolates values from two color: start and end color and the normalized coordinates from 0 to 1 in automatic mode?
    I wish use bilinear interpolation.
    I must create a texture with interpolated colors or is possible to set the bilinear interpolation in the creation of the sampler?

    next, is possible use integer coordinates(for ex from 0px to 600px) and interpolation in the same mode?

    thanks.

  2. #2
    Senior Member
    Join Date
    Oct 2012
    Posts
    165

    Re: opencl, images,samplers and interpolation

    Hi,

    to clarify this. You want to have an image of e.g. 600x600 pixels and you want to set (0:0) to white and (1.0:1.0) to Red and the sampler should interpolate all the values in between? Or do you want to interpolate between Pixel (0.5:0.5) and (0.6:0.5) in a bicubic way?

    In general it is possible to generate an interpolating sampler like in openGL. Check Chapter 5.5 in the openCL 1.1 spec or above if you need 1.2 spec. In 1.1 there is only non or linear interpolation available.

    And you don't have to use normalized coordiantes to access the image. This is also described in the spec.

    Greetings,
    clint3112

  3. #3

    Re: opencl, images,samplers and interpolation

    You want to have an image of e.g. 600x600 pixels and you want to set (0:0) to white and (1.0:1.0) to Red and the sampler should interpolate all the values in between?
    yes .
    thanks.

  4. #4
    Senior Member
    Join Date
    Oct 2012
    Posts
    165

    Re: opencl, images,samplers and interpolation

    you could create an image containing of 4 pixels, with your defined colors. After upscaling that with bicubic interpolation you should get what you want. but again, this is not available in opencl 1.1

    You could write a kernel that computes that image quite easy like in that pseudocode. thats just for x dimension. so you need to interpolate these 4 values correctly with the global id's of both dimensions
    Code :
    __kernel interpolate(inImage2x2, outImage600x600)
    {
        outimage[workitemindex] = inimage[0,0] * globalid(0) + 1.- inimage[0,1] * (globalsize(0) - globalid(0));
    }

    Greetings,
    clint3112

  5. #5
    Senior Member
    Join Date
    Dec 2011
    Posts
    152

    Re: opencl, images,samplers and interpolation

    clint, the OP asked about bilinear interpolation, not bicubic.

    OpenCL supports bilinear interpolation and can use normalize or unnormalized coordinates. As I interpret the original posting, the answer is "yes, OpenCL can do that". Read the section of the specification regarding samplers. You want to use read_imagef with float coordinates. The underlying image can be 8-bit or other formats but this API already returns a float4 pixel and can do bilinear interpolation.

  6. #6

    Re: opencl, images,samplers and interpolation

    thanks, i saw in the specification 1,1 and the CLK_FILTER_LINEAR parameter sets the linear interpolation for the sampler_t, but :
    1)how i can set the start color and the final color?
    2)what kind of image i must read with the sampler_t and what are the resolution if i use only two point(the start color and the final color)?
    Is possible using only two color?
    I'm sorry, but i don't understand .
    thanks.

  7. #7
    Senior Member
    Join Date
    Oct 2012
    Posts
    165

    Re: opencl, images,samplers and interpolation

    If you just want a grayscale with startcolor white, endcolor black, use an 1D kernel, pass the thwo colors and execute each item to divide the color. Or create an 1D image with only two pixels and interpolate them to a larger resolution.

  8. #8

    Re: opencl, images,samplers and interpolation

    thanks.
    Is possible create a four color interpolation in a rectangle , one interpolation for the x and one interpolation for the y.
    My goal is to take two color : from color A to color B and find the distance with the difference of B -A.

    Is an idea ,I wish do it for manage the collisions with opencl of a world in opengl.
    In theory i can do the same in 3d ,
    I save for each boundingbox the interpolated color of his position(under there is the interpolated image that have an interpolate color based on the distance from x and y)and use a sort (parallel like radixsort)algorithm for find all the possible collision that are the groups of more similar color , if two object have the same color collide.
    Then i can move the moved entities and simply refresh a part or the entire world with a sort algorithm in opencl.
    Is also usefull for know the neighbors entities of a light source for apply the light only at a range of entities at distance -RANGE- ecc...
    Is only an idea.
    by.

  9. #9

    Re: opencl, images,samplers and interpolation

    the idea is completely wrong.
    don't has a sense look up a color from an iterpolation , when i have the x and the y , but is sufficent create a sort algorithm with an index that has two or more values, exist sort algorithms that do that?(the sort of a set with more than one index?)
    thanks.

Similar Threads

  1. Question about OpenCL samplers
    By xargon in forum OpenCL
    Replies: 2
    Last Post: 07-03-2012, 08:28 PM
  2. loading images opencl
    By mkru in forum OpenCL
    Replies: 0
    Last Post: 12-18-2010, 07:20 AM

Posting Permissions

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