import cv2
import numpy as np
import matplotlib.pyplot as plt
filename = 'C:\Users\86186\Desktop\lemn.png'
src = cv2.imread(filename, 1)
cv2.imshow('img', src)
cv2.waitKey(0)
print(src.shape)
print(src.shape[:2])
print(src.shape[:3])
print(src.shape[0])
print(src.shape[1])
print(src.size)
print(src.dtype)
img = np.array([
[[255, 0, 0], [0, 255, 0], [0, 0, 255]],
[[255, 255, 0], [255, 0, 255], [0, 255, 255]],
[[255, 255, 255], [128, 128, 128], [0, 0, 0]],], dtype=np.uint8)
plt.imsave('img_pyplot.jpg',img)
cv2.imwrite('img_cv2.jpg', img)
cv2.imwrite('1.png', img, [int(cv2.IMWRITE_JPEG_QUALITY), 95])
cv2.imwrite('1.png', img, [int(cv2.IMWRITE_PNG_COMPRESSION), 9])
srccopy = src.copy()
cv2.imshow('srccopy.png',srccopy)
cv2.waitKey(0)
cv2.imshow('srcflip', cv2.flip(srccopy, -1))
cv2.waitKey(0)
res = cv2.resize(srccopy, None, fx=1, fy=2,interpolation =cv2.INTER_CUBIC )
cv2.imshow('res.png', res)
cv2.waitKey(0)
h = srccopy.shape[0]
w = srccopy.shape[1]
dsize = (h, w)
m=np.float32([[1,0,100],[0,1,50]])
src2 = cv2.warpAffine(srccopy,m,dsize)
cv2.imshow('src2.png', src2)
cv2.waitKey(0)
n = cv2.getRotationMatrix2D((w/2,h/2),60,0.5)
src3 = cv2.warpAffine(srccopy,n,dsize)
cv2.imshow('rotation',src3)
cv2.waitKey(0)