Run the OpenCV documentation and note what I'm a beginner and noticed
I'm ignorant about image recognition, so my motive is to deepen my understanding of OpenCV.
OpenCV has a function to add images However, the image sizes must be the same.
I read the official document for the first time, but is the image used here provided somewhere ...
#Load two images of the same size
img1 = cv2.imread('linux.jpg')
img2 = cv2.imread('windows.jpg')
#Weight the image
#This time img1=0.7, img2= 0.It is 3
dst = cv2.addWeighted(img1,0.7,img2,0.3,0)
#Depict
cv2.imshow('dst',dst)
#If you want to quit, just press some key
cv2.waitKey(0)
cv2.destroyAllWindows()
Since an image is a collection of pixels, the entire image can be captured as a matrix. Pixels are matrix elements Therefore, you can enlarge, reduce, or move the image by multiplying it by a scalar multiple matrix.
rows,cols = img.shape
#Move only the number specified in the third column of the matrix in the x and y-axis directions
#Since the image size is specified as 1, it is the same size.
M = np.float32([[1,0,100],[0,1,50]])
dst = cv2.warpAffine(img,M,(cols,rows))
cv2.namedWindow('img', cv2.WINDOW_NORMAL)
cv2.imshow('img',dst)
cv2.waitKey(0)
cv2.destroyAllWindows()
Adjust the 1-by-1 and 2-by-2 values to scale the image
I will update it from time to time
Recommended Posts