Kernel-based image convolution with variable kernel sizes