Python|OpenCV-Access and modify image pixel values, identify color and gray images (6)

Preface

This article is the 6th of this column. I will continue to share the practical knowledge of OpenCV computer vision later, so remember to pay attention.

When using OpenCV to operate images, you usually need to be proficient in some Numpy knowledge points. Because sometimes it is necessary to combine Numpy and OpenCV to implement image operations, so the best way to write better OpenCV code is to have a reserve of Numpy knowledge.

In this article, we will combine Numpy and OpenCV to introduce in detail " access and obtain the pixel value of the image, how to correctly modify the pixel value of the image ", and " how to correctly identify color images and gray images " and other knowledge points. The details can be viewed directly below. text. (complete code attached)

text

1. Use OpneCV to access image pixel values

Before starting, we first prepare a random picture "test.jpg" on the desktop. As follows:

Note : You can change the name of the picture on the desktop here at will. The code in the article only uses test.jpg as an example.

First, let's load an image. The sample code is as follows:

Guess you like

Origin blog.csdn.net/Leexin_love_Ling/article/details/133232508