So, the full code will look like this:
import cv2
image = cv2.imread('example.jpg')# Replace 'example.jpg' with the path to
your image
grayscale_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
cv2.imshow('Grayscale Image', grayscale_image)
cv2.waitKey(0)
cv2.destroyAllWindows()
Fig.3.36: converting an image to grayscale
EXERCISES
A. Multiple Choice Questions:
1. The field of study that helps to develop techniques to help computers “see”
is________________.
a. Python b. Convolution c. Computer Vision d. Data Analysis
2. Task of taking an input image and outputting/assigning a class label that best describes
the image is ____________.
a. Image classification b. Image localization
c. Image Identification d. Image prioritization
3. Identify the incorrect option
(i) computer vision involves processing and analysing digital images and videos
to understand their content.
(ii) A digital image is a picture that is stored on a computer in the form of a
sequence of numbers that computers can understand.
(iii) RGB colour code is used only for images taken using cameras.
(iv) Image is converted into a set of pixels and less pixels will resemble the original
image.
a. ii b. iii c. iii & iv d. ii & iv
4. The process of capturing a digital image or video using a
digital camera, a scanner, or other imaging devices is related to ________.
a. Image Acquisition b. Preprocessing
c. Feature Extraction d. Detection
5. Which algorithm may be used for supervised learning in computer vision?
a. KNN b. K-means c. K-fold d. KEAM
6. A computer sees an image as a series of ___________
a. colours b. pixels c. objects d. all of the above
78
7. ____________ empowers computer vision systems to extract valuable insights and
drive intelligent decision-making in various applications, ranging from autonomous
driving to medical diagnostics.
a. Low level processing b. High insights
c. High-level processing d. None of the above
8. In Feature Extraction, which technique identifies abrupt changes in pixel intensity
and highlights object boundaries?
a. Edge detection b. Corner detection
c. Texture Analysis d. boundary detection
9. Choose the incorrect statement related to preprocessing stage of computer vision
a. It enhances the quality of acquired image
b. Noise reduction and Image normalization is often employed with images
c. Techniques like histogram equalization can be applied to adjust the distribution
of pixel intensities
d. Edge detection and corner detection are ensured in images.
10. 1 byte = __________ bits
a. 10 b. 8 c. 2 d. 1
B. Short Answer Questions
1. What is Computer Vision?
Ans - Computer Vision is a field of artificial intelligence (AI) that uses digital images and
deep learning models to help systems understand and interpret the visual world.
2. What is the main difference between classification and detection?
Ans - The main difference between classification and detection is that classification
considers the image as a whole and determines its class whereas detection identifies the
different objects in the image and classifies all of them.
3. Write down any two algorithm which can be used for object detection.
Ans- Algorithms used for object detection are: R-CNN (Region-Based Convolutional
Network) and R-FCN (Region-based Fully Convolutional Network).
4. Write down the process of object detection in a single object.
Ans- Single object tasks focus on analyzing individual objects within an image, with two
main objectives:
Classification: - This task involves determining the category or class to which a single object
belongs, providing insights into its identity or nature.
Classification + Localization: In addition to classifying objects, this task also involves
precisely localizing the object within the image by predicting bounding boxes that tightly
enclose it.
79
5. Write any four applications of computer vision.
Ans –
1)Facial recognition: Popular social media platforms like Facebook uses facial recognition
to detect and tag users.
2)Healthcare: Helps in evaluating cancerous tumours, identify diseases or abnormalities.
Object detection & tracking in medical imaging
3)Surveillance: Live footage from CCTV cameras in public places helps to identify
suspicious behaviour, identify dangerous objects, and prevent crimes by maintaining law
and order.
4)Fingerprint recognition and biometrics: Detects fingerprints and biometrics to validate a
user's identity.
C. Long Answer Questions
1. What do you mean by Image segmentation? Explain the popular segmentations?
Ans - Image segmentation creates a mask around similar characteristic pixels and
identifies their class in the given input image. Image segmentation helps to gain a better
understanding of the image at a granular level. Pixels are assigned a class and for each
object, a pixel-wise mask is created in the image. This helps to easily identify each object
separately from the other. Techniques like Edge detection which works by detecting
discontinuities in brightness is used in Image segmentation. Two of the popular
segmentation are:
Semantic Segmentation: It classifies pixels belonging to a particular class. Objects
belonging to the same class are not differentiated. In this image for example the pixels are
identified under class animals but do not identify the type of animal.
Instance Segmentation: It classifies pixels belonging to a particular instance. All the
objects in the image are differentiated even if they belong to the same class. In this image
for example the pixels are separately masked even though they belong to the same class
2. Explain the challenges faced by computer vision.
Ans - The Challenges faced by Computer vision are:
1. Reasoning and Analytical Issues: Robust reasoning and analytical skills are
essential for defining attributes within visual content. Without such capabilities,
extracting meaningful insights from images becomes challenging.
2. Difficulty in Image Acquisition: Image acquisition in computer vision is hindered by
various factors like lighting variations, perspectives, and scales. Understanding
complex scenes with multiple objects and handling occlusions adds to the
complexity. Obtaining high-quality image data amidst these challenges is crucial for
accurate analysis and interpretation.
3. Privacy and Security Concerns: CV raises privacy concerns, potentially infringing
upon individuals' privacy rights. Regulatory scrutiny and public debate surround the
use of such technologies, necessitating careful consideration of privacy implications.
4. Duplicate and False Content: Computer vision introduces challenges related to the
proliferation of duplicate and false content. Data breaches pose a significant threat,
80
leading to the dissemination of duplicate images and videos, fostering
misinformation and reputational damage.
COMPETENCY BASED QUESTIONS:
1. A group of students is participating in a photography competition. As part of the
competition, they need to submit digitally captured images of various landscapes.
However, one of the students, Aryan, is unsure about how to ensure the best quality for
his images when digitizing them. Explain Aryan how the resolution of his images can
impact their quality and detail when viewed on a computer screen or printed.
Ans: Resolution determines the quality and level of detail in an image. Higher resolution
images contain more pixels, resulting in clearer and more detailed representations of
the landscapes.
2. The Red Fort is hosting a grand cultural event, and keeping everyone safe is top priority!
A state-of-the-art security system utilizes different "FEATURE EXTRACTION " to analyse
live video feeds and identify potential issues. Identify the feature extraction technique
that can be used in the following situation.
a. A large bag is left unattended near a crowded entrance.
b. A person tries to climb over a wall near a blind spot.
c. A group of people starts pushing and shoving in a congested area.
d. A wanted person with a distinctive red scarf enters the venue.
Ans: a. Texture Analysis
b. Edge detection
c. Corner detection
d. Colour based extraction
3. Which image segmentation technique would be most effective in this scenario: semantic
segmentation or instance segmentation?
a. You are developing a quality control system for a manufacturing plant. The system
needs to analyse images captured by cameras above a conveyor belt to identify
and isolate defective products.
b. You are assisting urban planners in developing a comprehensive land-use map for
a growing city. They require analysis of aerial imagery to classify large areas into
distinct categories like "buildings," "roads," "vegetation," and "parks."
Ans:
a. Instance Segmentation
b. Semantic Segmentation
81
4. Shreyan joined an architecture firm wherein he was asked to check if AI could be used
to create a detailed, representation of a city district for urban planning purposes, utilizing
computer vision techniques and data integration from aerial imagery, topographic
surveys, and architectural blueprints. Help him identify the application of computer
vision that can be used for the same.
Ans: 3D Model building using computer vision
5. You work for a fact-checking website. Lately, there's been a surge in INCORRECT news
articles and videos online, often manipulated using computer vision techniques. These
manipulations can make real people appear to be saying things they never did. What is
the concern here?
Ans. False/Fake content
References:
1. https://www.ibm.com/topics/computer-vision
2. https://www.datacamp.com/tutorial/seeing-like-a-machine-a-beginners-guide-
to-image-analysis-in-machine-learning
3. https://medium.com/@edgeneural.ai/computer-vision-making-the-machines-
see-361a3d0cfc3f
4. https://www.javatpoint.com/computer-vision
82