Image Processing Read & write image in Computer Vision..

Nikhil Upadhyay
Knowledge Gurukul
Published in
2 min readMar 11, 2021

Python holds wide variety of tools and libraries to read and writing images for image processing such as Open CV, PIL and skimage. Here in this Post we will understand how we can write image via Computer Vision.

An image is considered as a matrix of range of values from 0 to 255 (uint8) which are called as pixels.For any colour image there are three channels, i.e Red, Green, and Blue. A matrix is formed for each channel and these matrix are joined to give the pixel value at each point and For a black and white image only one channel exists which displays the pixel value.

So lets go to Understand how we can load image from our system and how we can show it into a new window.

Import Dependencies which required for working with Open-CV :

First of all import Open-CV in Python for windows and Ubuntu or Mac user Run this command in terminal or in cmd and if you are using Virtual env then install it into Virtual env by running this below command.

  • First of all an image is loaded using imread function.
  • Use the function imread()to read an image. Take care you give the path of the image.

As there are different type of images, so we use a second argument which is a flag that specifies the way image should be read.

  • cv2.IMREAD_COLOR: Loads a colour image.
  • cv2.IMREAD_GRAYSCALE: Loads image in grayscale mode.
  • cv2.IMREAD_UNCHANGED: Loads image as such including alpha channel.

Here in this loading and showing image in new window via open-CV Python.

So, Now we will Understand how we can save the load image video as copy of the image or we can save the load image video into grayscale mode.

So basically this are the code to load image and save image.

--

--

Nikhil Upadhyay
Knowledge Gurukul

Experience in AI(Computer Vision), Machine Learning, Python, Data Science and Proficient in Data Analysis, Predictive modelling, NLP, Database(SQL,