三原色顺序
when working with | Conversion |
---|---|
Matplotlib | M x N x 3 image, where last dimension is RGB. |
OpenCV | M x N x 3 image, where last dimension is BGR |
Scientific Cameras | some output M X N x 3 image, where last dimension is GBR |
三原色顺序转换
type | code |
---|---|
BGR to RGB | rgb = bgr[…,::-1].copy() |
RGB to BGR | bgr = rgb[…,::-1].copy() |
RGB to GBR | gbr = rgb[…,[2,0,1]].copy() |
The axis order convention for Python images
python图像的维数 | 代表的意思 |
---|---|
3 | W x H x 3, where the last axis is color (e.g. RGB) |
4 | W x H x 3 x 1, where the last axis is typically an alpha channel |
三种处理图片的方式
这两个路径和你运行的代码是在同一级的
dir1=“1.png”
dir2=“2.png”
类别 | 读取图片 | 保存图片 | 类型 |
---|---|---|---|
PIL | image = Image.open(dir1) | image.save(dir2) | PIL |
cv2 | image = cv2.imread(dir1) | cv2.imwrite(dir2, image) | numpy.ndarray(uint8) |
skimage | image = io.imread(dir1) | io.imsave(dir2,image) | numpy.ndarray(uint8) |
cv2类型不能有中文,特别注意一下。