图像翻转import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
path = "baidu_bear.png" # 图片路径
image = Image.open(path)
image = np.array(image)
#在下面补充相关代码
import cv2
dst = cv2.flip(image,0)
plt.imshow(dst)
图像裁剪import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
path = "baidu_bear.png" # 图片路径
image = Image.open(path) #读取图片
image = np.array(image)
#在下面补充相关代码
bigbear = image[20:400,5:300]
plt.imshow(bigbear)
图像亮度变换import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
path = "baidu_bear.png" # 图片路径
image = Image.open(path) #读取图片
image = np.array(image)
#在下面补充相关代码
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
banl = hsv.copy()
banl[:, :, 2] = 0.5 * hsv[:, :, 2]
banl = cv2.cvtColor(banl, cv2.COLOR_HSV2BGR)
shuanl = hsv.copy()
shuanl[:, :, 2] = 2* hsv[:, :, 2]
shuanl = cv2.cvtColor(shuanl, cv2.COLOR_HSV2BGR)
plt.imshow(banl)
图像色调变换import numpy as np
import matplotlib.pyplot as plt
from PIL import Image
path = "baidu_bear.png" # 图片路径
image = Image.open(path) #读取图片
image = np.array(image)
#在下面补充相关代码
import cv2
b = [255,255,255]-image
new=Image.fromarray(b.astype('uint8'))
plt.imshow(new)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)