While reading OpenCL 1.1 spec about CLK_FILTER_LINEAR (section 8.2, p258), I came to know that for calculating weights of bilinear filter 0.5 will be subtracted as shown below.
i0 = address_mode((int)floor(u – 0.5))
j0 = address_mode((int)floor(v – 0.5))
i1 = address_mode((int)floor(u – 0.5) + 1)
j1 = address_mode((int)floor(v – 0.5) + 1)
While for CLK_FILTER_NEAREST, it directly floor the u and v as below:
i = address_mode((int)floor(u))
j = address_mode((int)floor(v))
So, there seems to be discrepancy. When I provide unnormalized coordinates (5,4) NEAREST filter will read pixel (5,4). And for LINEAR filter will produce average pixel from (4,3), (5,3), (4,4) and (5,4). But even for LINEAR filter I would expect to read from (5,4) because weights will be 1, 0, 0, 0.
Can anyone please clarify the spec intention?
It's true. If you want to read a non-interpolated pixel, you'll need to add (0.5,0.5) to the coordinate. "Round" numbers (ending in .0) sit between the pixels and will be equally blended.