import matplotlib.pyplot as plt
import numpy as np
fish = plt.imread('fish.jpg')
plt.imshow(fish)
图像旋转
镜像旋转
# 镜像旋转
fish1 = fish[:,::-1,:]
plt.imshow(fish1)
上下倒置
# 上下倒置
fish2 = fish[::-1,:,:]
plt.imshow(fish2)
上下左右全相反
# 镜像倒置
fish3 = fish[::-1,::-1,:]
plt.imshow(fish3)
顺时针旋转90度
transpose()转秩
三维的维度对应的 0 1 2
# 顺时针旋转90度
# transpose()转秩
fish4 = fish.transpose((1,0,2))[:,::-1,:]
plt.imshow(fish4)
逆时针旋转90度
# 逆时针旋转90度
fish5 = fish.transpose((1,0,2))[::-1,:,:]
plt.imshow(fish5)
颜色处理
反色
# 反色处理
fish6 = fish[:,:,::-1]
plt.imshow(fish6)
图像剪切与拼接
拼接
fish11_0 = np.concatenate((fish,fish))
plt.imshow(fish11_0)
在这里插入图片描述
fish11_1 = np.concatenate((fish,fish),axis=1)
plt.imshow(fish11_1)
剪切
fish_ = np.split(fish,(100,420))[1]
plt.imshow(fish_)
fish__ = np.split(fish_,(30,470),axis=1)[1]
plt.imshow(fish__)