计算机视觉入门
打开,操作,保存图片
多种读取的操作
numpy查询文档
偏基础的图像处理教程
基于python的教程
tips
- cv2的保存的顺序是b, r, g
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| # -*- coding: utf-8 -*- """ Created on Tue Aug 14 16:23:42 2018
@author: 宝宝天龙 """ from PIL import Image import numpy as np import matplotlib.pyplot as plt import matplotlib.image as mp if __name__ == "__main__": img=np.array(Image.open('cat.jpg')) #打开图像并转化为数字矩阵 #plt.imshow(img) #plt.axis('off') print(img.shape) rows, cols, dim = img.shape for i in range(0, 5000): x = np.random.randint(0, rows) y = np.random.randint(0, cols) img[x, y] = [255, 255, 255] plt.imshow(img) print(img.shape) plt.axis('off') #这个函数会改变图片的大小 #plt.savefig("cat1.jpg") mp.imsave('cat2.jpg', img)
|
缩小图片
图片放大就在里面改改就行了
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| # -*- coding: utf-8 -*- """ Created on Tue Aug 14 16:23:42 2018
@author: 宝宝天龙 """ from PIL import Image import numpy as np import matplotlib.pyplot as plt import matplotlib.image as mp if __name__ == "__main__": img=np.array(Image.open('cat.jpg')) #打开图像并转化为数字矩阵 #plt.imshow(img) #plt.axis('off') print(img.ctypes) rows, cols, dim = img.shape # dtype如果为short则,则图片显示的很不正常 small = np.zeros((rows print(img.shape) for i in range(0, rows, 2): for j in range(0, cols ,2): small[i print(small.shape) print(small[0, 0], img[0, 0]) plt.imshow(small) #plt.imshow(img) print(img.shape) plt.axis('off') #这个函数会改变图片的大小 #plt.savefig("cat1.jpg") mp.imsave('cat2.jpg', img) mp.imsave("cat3.jpg", small, dpi=100, format = "jpg")
|
homework1 教程
高通滤波器的实现原理
- 图片数据类型的转换
- 引用类型的变参
homework2
问题
教学视频
opencv官方文档
未解决的问题