This Is How Easy it Is to Read and Display Images

Written by shehzensidiq | Published 2022/12/01
Tech Story Tags: image-processing | machine-learning | image-recognition | image-classification | guide | how-to | beginners-guide | cv

TLDROpen CV library lets us do all the stuff with the images that we can imagine. In today’s post, we will explore 2 functions of Open Cv: `imread` and `imshow`; which do what their name suggests. Imread is used to read an image, and 'imshow' can be used to display the images using an open cv library. Imshow is used for the display of an arbitrary window name, and ‘window name’ is any arbitrary name for the displaying of images.via the TL;DR App

So OPEN cv, HUH!

Yes! Why Not!!

Okay, then.

Since working with images is becoming more and more popularized, we are going to take a dive into this field, going from the basics and starting with the OPEN CV library. Which lets us do all the stuff with the images that we can imagine.

In today’s post, we will explore 2 functions of Open Cv: imread and imshow; which do what their name suggests.

imread is used to read an image, and imshow is used to display the images using an open cv.

Let us first import the library we need.

import opencv as cv2

Now, let us explore today’s jungle of open cv and find the meaning and working of two 👑s of this jungle.

imread()

So, this function is used to read an image, given the path of the image is correct 🤣.

im = cv2.imread("path to the image")

We must know that the image read -

  1. it is read in BGR color format and not the RGB format.

  2. Behind every image is a set of pixels, so if we print the im, we will get the NumPy array.

If we want to display the image and not the nd array, we must use imshow function and not the print function.

What it does is it reads the pixel values and displays those based on the color channel of the image.

cv2.imshow("window name", image)

image is the numpy nd array, and ‘window name’ is any arbitrary name for the window that pops up for the displaying of images.

Conclusion

So, this is how easy is it to read and then display images using an open cv. I hope you got an understanding of these concepts.

Thank you for reading and See you in the next post


Written by shehzensidiq | I am a learner just like you. I am trying to explore the field of AI and its various aspects and dimensions.
Published by HackerNoon on 2022/12/01