OpenCV-Python is the Python library designed to solve computer vision problems. We can read the Image using the  imread() function, write or save the Image using the  imwrite() function, display the image in the image window using the  imshow() method.

How to Access Pixel Data in Image

To access pixel data in Image, use  numpy and opencv-python library. Import numpy and cv2(opencv-python) module inside your Python program file. Then read the image file using the imread() function. The imread() Method takes two parameters.

  1. Image path
  2. Channel(If 1 then black and white and if 2 then color)

Let’s print the Image.

## app.py

import numpy as np
import cv2

img = cv2.imread('forest.jpg', 1)

print(img)

#python #python opencv #opencv-python

How to Access Pixel Data in Image using Python OpenCV
2.20 GEEK