如何为numpy数组添加运动模糊

时间:2016-10-28 13:16:35

标签: python image python-imaging-library blur

我有一个来自图像的numpy数组

那么,是否有一个好方法:/x/y

4 个答案:

答案 0 :(得分:4)

awk
您可以找到here

的解释

答案 1 :(得分:2)

绘制一条旋转的线作为内核,然后将卷积滤镜应用于具有该内核的图像。

下面的代码使用opencv框架。

import cv2
import numpy as np

#size - in pixels, size of motion blur
#angel - in degrees, direction of motion blur
def apply_motion_blur(image, size, angle):
    k = np.zeros((size, size), dtype=np.float32)
    k[ (size-1)// 2 , :] = np.ones(size, dtype=np.float32)
    k = cv2.warpAffine(k, cv2.getRotationMatrix2D( (size / 2 -0.5 , size / 2 -0.5 ) , angle, 1.0), (size, size) )  
    k = k * ( 1.0 / np.sum(k) )        
    return cv2.filter2D(image, -1, k) 

答案 2 :(得分:0)

我会使用matplotlib

from PIL import Image
img = Image.open('your_image')
imgplot = plt.imshow(img, interpolation="bicubic")

答案 3 :(得分:0)

如果要垂直应用,可以使用以下内核:

curl --request PUT \
  --url INSTANCE/services/data/v44.0/jobs/ingest/JOB_ID/batches \
  --header 'authorization: Bearer TOKEN' \
  --header 'content-type: text/csv' \
  --data '"Id,Entity_Name__c\n001,One\n002,Two\n003,Three"'
相关问题