Motion Blur Filters

Motion Blur Custom Kernel Filter in Python

         You can create a custom kernel by placing elements in a specific way, like along a horizontal line. In this setup, the central pixel value is figured out by looking at the average of these pixels, creating the 'Motion Blur' effect. When certain elements have higher importance, they impact the final pixel value more in the Motion Blur effect. Making sure the total of all these elements adds up to 1 helps keep the original brightness of the picture. The freedom to arrange elements in different directions lets you make various motion effects in the image.

# custom MotionBlur horizontal 7x7 kernel
[
  [ 0,    0,    0,    0,    0,   0,    0    ],
  [ 0,    0,    0,    0,    0,   0,    0    ],
  [ 0,    0,    0,    0,    0,   0,    0    ],
  [ 0.15, 0.15, 0.15, 0.1,  0.15, 0.15, 0.15],
  [ 0,    0,    0,    0,    0,   0,    0    ],
  [ 0,    0,    0,    0,    0,   0,    0    ],
  [ 0,    0,    0,    0,    0,   0,    0    ],
]

         This effect imitates the case of a camera moving horizontally while capturing a photo, generating the illusion of motion in the image.

Original image
MotionBlur filter
Original vector image
Custom Motion blur 7x7 horizontal kernel filter in Python
Custom MotionBlur kernel filter

Python code example

         The provided Python code example demonstrates how to utilize the Aspose.Imaging Python API. You can use the `ConvolutionFilter` class, which provides pre-defined kernel filters like get_blur_motion() with customizable size and angle parameters. Moreover, you retain the freedom to design your custom kernel matrix. In this instance, image templates in raster PNG and as well as vector SVG formats are loaded from the "templates" directory, and a set of filters is applied from the `kernel_filters` list.