Image Processing In Python Using openCV

We know that image is combination of multiple rows & columns i.e. multi-dimentional array. Black & white images are 2D arrays and coloured imges are the 3D.
What is Image Processing?
Image processing is a method to perform some operations on an image, in order to get an enhanced image or to extract some useful information from it. It is a type of signal processing in which input is an image and output may be image or characteristics/features associated with that image.
First of all we need #opencv-python library
Install OpenCV through following pip command
#pip install opencv-python
Let’s understand basic commands :
img = cv2.imread(“path”) :For reading the image, use the imread() method of the cv2 module. path is varible whish shows the image source.
2. cv2.imshow(‘name’, variable_name):This command is used to show the image .
3. cv2.waitKey():The waitkey() functions take time as an argument in milliseconds as a delay for the window to close. Here we an set the time to show the window forever until we close it manually.
4. cv2.destroyAllWindows():cv2.destroyAllWindows() function, pressing any key on keyboard is closing the image window.
5.img.shape :It displays the shape of image in (rows,columns,dimention)
6. cut_image = img[x1: x2, y1: y2]: you can crop the images using
#numpy slicing concept.
TASK -1 #Create image by yourself Using Python Code
Normally in opencv the order of colours are reverse
#BGR — colours order
#0- less then 255 range gives black or grey colour so for black image we took numpy. Zeros( )

Task 2 - image crop some part of both image and swap it.

Task 3- Take 2 image and combine it to form single image.

-That all
Thank you.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store