You are currently viewing How to Read and Show Image using OpenCV

How to Read and Show Image using OpenCV

One of the most popular ways to open and show image is the CV2 module. This module allows for a wide range of image file formats to be read and show image iusing OpenCV in Python, including jpeg, png, and tiff. The module also supports a variety of different color spaces, such as RGB, HSV, and LAB. With these options, the user can create powerful algorithms that take advantage of what we know about how our eyes see colors.

One of the most popular ways to open and show image is the CV2 module. This module allows for a wide range of image file formats to be read and show image iusing OpenCV in Python, including jpeg, png, and tiff. The module also supports a variety of different color spaces, such as RGB, HSV, and LAB. With these options, the user can create powerful algorithms that take advantage of what we know about how our eyes see colors.

Read Image using OpenCV Code:

import cv2
img_cv2 = cv2.imread('/content/solar.jpeg')
print(img_cv2)

Output:

[[[30 15 23]
  [33 18 26]
  [36 20 31]
  ...
  [40 15 19]
  [38 12 18]
  [39 10 19]]

 ...

 [[ 4  4  4]
  [ 4  4  4]
  [ 4  4  4]
  ...
  [ 4  4  4]
  [ 4  4  4]
  [ 4  4  4]]]

Show Image using OpenCV Code:

cv2.imshow('Solar Image',img_cv2)
cv2.waitKey(0)
cv2.destroyAllWindows()

A pop up window of the image will be appeared as an output.

Other Python Libraries to Read Images:

How to Read and Show Image using Skimage

How to Read and Show Image using Matplotlib

How to Read and Show Image using Pillow

How to Read and Show Image using Imageio

Leave a Reply