0% found this document useful (0 votes)
11 views2 pages

Open CV

OpenCV is an open-source computer vision and machine learning library developed by Intel, supporting multiple programming languages and offering various functions for image processing and video analysis. Key applications include face recognition, object detection, medical image processing, and augmented reality. The document also discusses computer vision concepts, image processing steps, and provides examples of using OpenCV with Python.

Uploaded by

suraj240423
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views2 pages

Open CV

OpenCV is an open-source computer vision and machine learning library developed by Intel, supporting multiple programming languages and offering various functions for image processing and video analysis. Key applications include face recognition, object detection, medical image processing, and augmented reality. The document also discusses computer vision concepts, image processing steps, and provides examples of using OpenCV with Python.

Uploaded by

suraj240423
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

# 1. Describe OpenCV and Explain Any Four Applications.

OpenCV (Open Source Computer Vision Library) is an open-source


computer vision and machine learning library developed by Intel. It
provides various functions for image processing, video analysis, and
machine learning. OpenCV supports multiple programming languages,
including Python, C++, and Java.
Applications of OpenCV:
1. Face Recognition & Detection: Used in security systems and social
media platforms for facial authentication.
2. Object Detection: Used in autonomous vehicles, surveillance, and
robotics.
3. Medical Image Processing: Helps in analyzing X-rays, MRIs, and CT
scans.
4. Augmented Reality (AR): Used in apps like Snapchat filters and
virtual try-on systems.
4. Explain the Concept of Computer Vision.
Computer Vision is a field of AI that enables machines to interpret and
understand visual data. It involves techniques to process, analyze, and
extract meaningful information from images or videos. Common tasks
include:
Object detection
Image classification
Facial recognition
Edge detection
7. Discuss Different Steps Involved in Image Processing.
1. Image Acquisition: Capturing the image using a camera or reading
from a file.
2. Preprocessing: Noise removal, resizing, and contrast adjustment.
3. Segmentation: Separating objects of interest (e.g., edge detection).
4. Feature Extraction: Identifying key details (e.g., shape, texture).
5. Image Recognition/Analysis: Classifying and interpreting image
contents.
(15)Create a Python Script to Convert an RGB Image to Grayscale Using
OpenCV. python
import cv2
# Read the image
image = cv2.imread("image.jpg")
# Convert to grayscale
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Save and display
cv2.imwrite("gray_image.jpg", gray_image)
cv2.imshow("Grayscale Image", gray_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
# 17. Explain the Role of NumPy Arrays in Image Processing and Provide an Example.
OpenCV stores images as NumPy arrays.
Each pixel is represented as an array element, making operations efficient.
Example: Creating a Black Image Using NumPy
import numpy as np
import cv2
black_image = np.zeros((500, 500, 3), dtype=np.uint8)
cv2.imshow("Black Image", black_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
21. Describe the Steps Involved in Opening an Image File Using OpenCV.
1. Import OpenCV: import cv2
2. Read the Image: cv2.imread("image.jpg")
3. Display the Image: cv2.imshow("Image", image)
4. Wait for User Input: cv2.waitKey(0)
5. Close Windows: cv2.destroyAllWindows()
# 27. Difference Between Reading an Image as a Grayscale Image and a Color Image in
OpenCV.
ModeCodeDescription
Color Image
cv2.imread("image.jpg")
Reads in BGR format
Grayscale
cv2.imread("image.jpg", cv2.IMREAD_GRAYSCALE)
Reads single-channel image
Significance of Color Channels:
Color images use three channels (BGR), storing more information.
Grayscale images are efficient for edge detection and machine learning.
28. Common File Formats Supported by OpenCV and Their Pros & Cons.
FormatProsCons
JPEG 29 .Purpose of Image Transformation
Compressed, smaller size
Lossy compression, reduced quality Techniques in OpenCV.
PNG 1. Resizing: Adjusting dimensions for optimization.
Lossless, supports transparency resized = cv2.resize(image, (width, height))
Larger file size
BMP 2 .Rotating: Changing orientation.
Uncompressed, high quality rotated = cv2.rotate(image,
Huge file size cv2.ROTATE_90_CLOCKWISE)
TIFF
Best for editing and printing 3. Cropping: Extracting a region.
Not widely supported cropped = image[y1:y2, x1:x2]
34. Differences Between OpenCV’s cv2.line(), cv2.rectangle(), and cv2.circle()
Functions.
Function Purpose Example Usage
cv2.line()
Draws a straight line
cv2.line(img, (x1,y1), (x2,y2), color, thickness)
cv2.rectangle()
Draws a rectangle
cv2.rectangle(img, (x1,y1), (x2,y2), color, thickness)
cv2.circle()
Draws a circle
cv2.circle(img, center, radius, color, thickness)

You might also like