Opencv-python image processing learning essay: Why does the cv2.add function add two scalars to return a 4-element two-dimensional array

☞ ░ to the old ape Python Bowen directory

Look at the following case:

>>>import numpy as np
>>>import cv2
>>>img = cv2.add(1,2)
>>> img
array([[3.],
       [0.],
       [0.],
       [0.]])
>>> img.shape
(4, 1)

The execution is the addition of two scalars 1 and 2. Why is a two-dimensional array of 4 elements returned? The old monkey believes that it is because the opencv-python image operation process forces the image to be processed according to the four channels of BGRA, and The two scalars are forced to be converted to arrays in BGRA format.

For more information about OpenCV-Python, please refer to " OpenCV-Python Graphics and Image Processing ".

Paid column about the old ape

Lao Yuan’s paid column " Developing Graphical Interface Python Applications Using PyQt " specifically introduces the basic tutorials of PyQt graphical interface development based on Python, and the paid column " Moviepy Audio and Video Development Column " details the related methods and usage of moviepy audio and video editing and synthesis processing Method to process related editing and synthesis scenes. Both columns are suitable for novice readers who have a certain Python foundation but no relevant knowledge.

Paid column article catalog : " Moviepy audio and video development column article directory ", " Use PyQt to develop graphical interface Python application column directory ".

For those who lack Python foundation, you can learn Python from scratch through Lao Yuan’s free column " Column: Python Basic Tutorial Directory ".

If you are interested and willing to support the readers of Old Ape, welcome to buy paid columns.

Learn Python and OpenCV from the old ape!

☞ ░ to the old ape Python Bowen directory

Guess you like

Origin blog.csdn.net/LaoYuanPython/article/details/109017549