Chapter VI Image Processing
这一章的内容是最多的!!!
这章首先是基本的图像处理:translation,rotation,resizing,flipping,and cropping
然后是image arithmetic,bitwise operations,and masking
translation:

[1,0,25]的意思是往(1,0)的方向移动25个pixels,同理[0,1,50]的意思是往(0,1)的方向移动50个pixels
我猜想(1,1,50)的意思往(1,1)的方向移动50个pixels,这个猜想不对,见图:

接下来是Rotation:

(w,h)就是旋转的原点,getRotationMatrix2D的最后一个参数是the scale of the image,放缩比例
Resizing:

Flipping:



Cropping:
在前面的chapter用过cropping了,是通过numpy的slicing
Image Arithmetic
opencv的加法 和 numpy的加法是不一样的,越界了numpy是取模而opencv是取界限值

对图像所有像素加100和所有像素减50的效果:

BITWISE OPERATION:
4种基本的位操作:AND,OR,XOR,and NOT
如果有两个大小相等的图A和B 都是有黑或者白组成,
那么图A and 图b 两个都是白的区域 and出来还是白的,
图A or 图B 只要有一个图某个区域是白的 or出来就是白的
图A xor 图B 两个图某个区域都是白或者都是黑 xor出来的就是黑的其余的位置就是白的
Masking:
Using a mask allows us to focus only on the portions of the image that interests us
用黑白图与图像进行and操作就能得到cropping的效果
SPLITTING AND MERGING CHANNELS:
用split将图像分成三个通道的图像:分出来的是灰度图

灰度度变成彩色图:

COLOR SPACES:
除了RGB color space 还有很多其他的spaces
比如HSV Hue-Saturation-Value 或者 L*a*b*

康康扩展包https://ppao.pyimagesearch.com/lessons/ppao-chapter-6-image-processing/
扩展包里面有几个例子 关于不同color spaces的作用
网友评论