Custom C++ kernel implementation for image filtering