1
votes

I'm writing custom Core Image filters and I'm having a hard time really understanding the extent parameter of CIKernel's apply method.

In all documentation and WWDC talks I found so far it's described as the "domain of definition of the kernel", so the area for which the kernel produces meaningful, non-zero results.

From that definition I would assume that the extent of the output of a convolution kernel is the same as the extent of the input image, because a convolution always combins multiple input values into one output value. But in the examples that I found and from observations of behavior of the built-in kernels such as CIGaussianBlur, the output extent is always larger than the input (depending on the size if the convolution kernel).

I don't understand why. Why should the kernel produce results for pixels that lie outside of the original input domain?

1

1 Answers

0
votes

Under that definition of output extent, any output pixel where the input image and the kernel intersect is a valid pixel. For a kernel of 2*n+1 pixels in width, this definition adds n pixels on both sides of the image.

But there are other possible definitions. Sometimes you only need the part of the result where the kernel fully overlaps the input image. Here we subtract n pixels from both sides of the image.

But of course the most common definition in image processing is where the output image has the same size as the input image. It is most useful if the image doesn’t change size as it is being processed.