生活随笔
收集整理的這篇文章主要介紹了
最原始的图像处理
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
原圖
#!/usr/bin/python
# -*- coding:utf-8 -*-import numpy as np
import os
from PIL import Imagedef convolve(image, weight):height, width = image.shapeh, w = weight.shapeheight_new = height - h + 1width_new = width - w + 1image_new = np.empty((height_new, width_new), dtype=np.float)for i in range(height_new):for j in range(width_new):image_new[i,j] = np.sum(image[i:i+h, j:j+w] * weight)image_new = image_new.clip(0, 255)image_new = np.rint(image_new).astype('uint8')return image_newif __name__ == "__main__":A = Image.open("./son.png", 'r')print(A)output_path = './ImageConvolve/'if not os.path.exists(output_path):os.mkdir(output_path)a = np.array(A)print(a.shape)
總結(jié)
以上是生活随笔為你收集整理的最原始的图像处理的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。