[PYTHON] Read the OpenCV documentation

Purpose

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.

Image addition

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()

Geometric transformation of the image

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

Read the OpenCV documentation
Read the keras mnist sample
I read the SHAP paper
Read the Docs integration for sphinx-apidoc
I want to read the html version of "OpenCV-Python Tutorials" OpenCV 3.1 version
Run Pylint and read the results
How to read the SNLI dataset
Finding the simplest mistakes with OpenCV
Have python read the command output
Accelerate read by specifying OpenCV frame
Try blurring the image with opencv2
[Python] Read the Flask source code
Read the graph image with OpenCV and get the coordinates of the final point of the graph
I checked the options of copyMakeBorder of OpenCV
Try using the camera with Python's OpenCV
[OpenCV] About the array returned by imread
Until you can read the error log
Read all csv files in the folder
Let's read the RINEX file with Python ①
Have Voiceroid read the Twitter TL aloud
Read the file line by line in Python
I see, I will read the UNIX process
Get started with the documentation tool Sphinx
Read the file line by line in Python
Read the file by specifying the character code.
Read all the contents of proc / [pid]
[Python] Read images with OpenCV (for beginners)
I read the implementation of golang channel
Read the implementation of ARM global timer
[Python] Read the specified line in the file
Read the image posted by flask so that it can be handled by opencv