Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add motion blur to numpy array

I have a numpy array from image

So, is there a good way to do so: from PIL import Image a = Image.open('img') a = a.filter(MOTION_BLUR)

like image 734
qqq Avatar asked Dec 14 '22 02:12

qqq


1 Answers

import cv2
import numpy as np

img = cv2.imread('input.jpg')
cv2.imshow('Original', img)

size = 15

# generating the kernel
kernel_motion_blur = np.zeros((size, size))
kernel_motion_blur[int((size-1)/2), :] = np.ones(size)
kernel_motion_blur = kernel_motion_blur / size

# applying the kernel to the input image
output = cv2.filter2D(img, -1, kernel_motion_blur)

cv2.imshow('Motion Blur', output)
cv2.waitKey(0)

explanation you can found here

like image 74
Gaurav Pawar Avatar answered Dec 24 '22 15:12

Gaurav Pawar