open-cv open image
What is OpenCV
OpenCV stands for Open Source Computer Vision. It is a library used for computer vision and machine learning tasks. It provides many functions to process images and videos.
Computer Vision
Computer vision is the process of extracting information from images or videos. For example, it can be used for object detection, face recognition, and more.
Source Code
import cv2
image = cv2.imread("./data/openCV_logo.jpg",cv2.IMREAD_COLOR)
image = cv2.resize(image,(600,600))
cv2.imshow("window title",image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Image

OpenCV Functions
imread
This function is used to read an image and returns it as a NumPy array. It requires two arguments:
- Image path: The location of the image file.
- Read flag: Specifies the mode in which the image should be read. Common flags are:
- Color Image
- Grayscale Image
- Image with Alpha Channel
resize
This function resizes an image. It requires two arguments:
- Image array: The NumPy array of the image.
- Resolution: A tuple specifying the new width and height.
imshow
This function displays an image. It takes two arguments:
- Window name: A string representing the window title.
- Image array: The image to be displayed.
waitKey
This function adds a delay to the program and listens for keypress events.
- If the value is 0, the program waits indefinitely until a key is pressed.
- If a key is pressed, it releases the program and returns the ASCII value of the pressed key.
- Example: Pressing
q
returns113
.
destroyAllWindows
This function closes all open image windows and properly cleans up used resources.