IMAGE PROCESSING
BASIC OPERATIONS:
libraries required: numpy, cv2
To read the image : cv2.imread()
Parameters: cv2.imread(filename[,flags])
In the above parameter you can see that the mandatory requirement is the filename which can be passed as a string. The filename is the image which you want to be read by the computer.
gives the dimensions of the image : image.shape
to display image: cv2.imshow()
Parameters: cv2.imshow(window_name,image)
The window_name should be a string value and hence will be in enclose in double or single quotes. The image shall be the image which should be
NEED OF WAITKEY: This function is very important, without this function cv2.imshow() won’t work properly.
Parameters: cv2.waitkey(wait time in milliseconds)
Thus if the wait time is entered as 6000, the picture will be displayed for 6s and then get closed (provided you have cv2.destroyAllWindows() in the script). If you use ‘0’ as the parmater then the image will be displayed for infinite time until you press the esc key.
NEED OF DESTROYALLWINDOWS:This method destroys (in other words “closes”) all the windows created using the opencv methods. If you want to close a specific window, then you can pass the window name as the argument within this function
Parameters: name of a window opened using opencv (not mandatory)
Missing to provide the cv2.destroyAllWindows() at the end of the script might make the window opened to crash
TASK1:Create image by yourself Using Python Code
CODE:
OUTPUT:
TASK2:ake 2 image crop some part of both image and swap it.
CODE:
OUTPUT:
TASK3:
Take 2 image and combine it to form single image. For example collage
code:
OUTPUT: