Motion Blur Filters

Motion Blur Custom Kernel Filter in Java

         You can choose to create a custom kernel with elements arranged, for example, in a vertical orientation. In this situation, the pixel value is computed based on the weighted average of these pixels, resulting in the 'Motion Blur' image effect. Higher weights assigned to elements have a more pronounced impact on the final pixel value in the Motion Blur image effect. Ensuring the total sum of elements is equal to 1 helps preserve the original image's brightness. The ability to position elements in different directions provides flexibility for generating various motion effects in the image.

// custom vertical MotionBlur 5x5 kernel
{
  { 0, 0, 0.25, 0, 0 },
  { 0, 0, 0.2,  0, 0 },
  { 0, 0, 0.1,  0, 0 },
  { 0, 0, 0.2,  0, 0 },
  { 0, 0, 0.25, 0, 0 },
};

         This effect emulates the visual impression of camera movement occurring during photo capture in a vertical direction. It generates the illusion of motion within the image.

Original image
MotionBlur filter
Original photo before blur filter
Custom Motion blur 5x5 kernel filter in Java
Custom MotionBlur kernel filter

Java code example

         The provided Java code example illustrates the application of the Aspose.Imaging for Java API. Utilize the `ConvolutionFilter` class, which provides pre-defined kernel filters, including the GetBlurMotion() method with adjustable size and angle settings. Furthermore, you retain the flexibility to craft your personalized kernel matrix. Within this example, image templates in PNG and SVG formats are loaded from the "templates" folder, and a set of filters are applied from a predefined list.