I wrote the following Metal Core Image Kernel to produce constant red color.
extern "C" float4 redKernel(coreimage::sampler inputImage, coreimage::destination dest)
{
return float4(1.0, 0.0, 0.0, 1.0);
}
With the extent<\/code> parameter of the kernel call you signal the region for which the kernel produces meaningful results—or, as you correctly named it, the domain of definition<\/em> .
However, this also means that whatever it produces outside this region is basically undefined and up to you as the kernel developer to decide.
To restrict the output to a specific area, you can apply a crop to it:
let dod = inputImage.extent
let result = CIMetalTestRenderer.kernel.apply(extent: .infinite, roiCallback: { index, rect in
return rect
}, arguments: [inputImage])
return result.cropped(to: dod)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.