Python OpenCV Computer Vision
- 128Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is OpenCV primarily used for?
What is OpenCV primarily used for?
128 questions
- 1
What is OpenCV primarily used for?
- A
Compiling Python programs into machine code
- B
Processing and analyzing images and video
- C
Designing web pages and browser interfaces
- D
Managing relational databases and tables
Correct answer
BProcessing and analyzing images and video
Explanation
OpenCV is a computer vision library used for image and video processing, manipulation, and analysis.
- A
- 2
Which programming languages are identified as having OpenCV implementations?
- A
Python, C++, and Java
- B
C, Swift, and Kotlin
- C
Java, PHP, and MATLAB
- D
Python, Ruby, and JavaScript
Correct answer
APython, C++, and Java
Explanation
The content identifies OpenCV as a computer vision library available in Python, C++, and Java.
- A
- 3
What does computer vision primarily attempt to derive insights from?
- A
Text files and spreadsheets
- B
Audio recordings and music
- C
Source code and databases
- D
Images and video
Correct answer
DImages and video
Explanation
Computer vision focuses on deriving insights from visual media such as images and video.
- A
- 4
Which command checks the installed Python version from a terminal?
- A
pip --python-version - B
python --version - C
python --check-install - D
python --show-release
Correct answer
Bpython --versionExplanation
The command
python --versiondisplays the installed Python version. - A
- 5
What minimum Python version is recommended for the course code?
- A
Python 3.7 or newer
- B
Python 4.0 or newer
- C
Python 3.0 or newer
- D
Python 2.7 or newer
Correct answer
APython 3.7 or newer
Explanation
The material recommends using Python version 3.7 or above and warns that some code may not work with Python 2.
- A
- 6
Why is
opencv-contrib-pythonrecommended instead of onlyopencv-python?- A
It provides only the basic OpenCV functions without extras
- B
It automatically converts every image into grayscale
- C
It replaces Python with a faster compiled language
- D
It includes the main OpenCV module and community contribution modules
Correct answer
DIt includes the main OpenCV module and community contribution modules
Explanation
opencv-contrib-pythonincludes the main OpenCV functionality as well as additional contribution modules provided by the community. - A
- 7
What kind of operations is NumPy especially useful for in this course?
- A
Training only face-recognition classifiers
- B
Matrix and array manipulation
- C
Installing Python interpreters
- D
Video streaming over the internet
Correct answer
BMatrix and array manipulation
Explanation
NumPy is a scientific-computing package extensively used for matrix and array manipulation, transformation, and reshaping.
- A
- 8
What is the purpose of the utility package described as
sear?- A
To provide helper functions that speed up computer-vision workflows
- B
To replace OpenCV's image-reading functions
- C
To convert Python code into Java programs
- D
To provide a database for storing image labels
Correct answer
ATo provide helper functions that speed up computer-vision workflows
Explanation
The package is described as a collection of utility functions and helpers intended to speed up computer-vision workflows.
- A
- 9
What does
cv.imreadreturn when it successfully reads an image?- A
A matrix containing the image's pixels
- B
A list containing only the image filename
- C
A text description of the image
- D
A video-capture device object
Correct answer
AA matrix containing the image's pixels
Explanation
cv.imreadtakes an image path and returns the image as a matrix of pixels. - A
- 10
Which statement correctly describes a relative image path?
- A
It refers to a file relative to the current working directory
- B
It must begin with the computer's root directory
- C
It always identifies a file using a complete absolute path
- D
It can refer only to files stored on the internet
Correct answer
AIt refers to a file relative to the current working directory
Explanation
A relative path such as
photos/cat.jpgidentifies a file relative to the program's current working directory. - A
- 11
What does
cv.imshowdo?- A
It displays an image matrix in a new window
- B
It saves an image matrix as a compressed file
- C
It converts an image matrix into a video
- D
It calculates the number of pixels in an image
Correct answer
AIt displays an image matrix in a new window
Explanation
cv.imshowdisplays the supplied image matrix in a named window. - A
- 12
What is the effect of calling
cv.waitKey(0)?- A
It pauses the program for exactly zero frames
- B
It continuously records keyboard input into a file
- C
It waits for zero milliseconds and immediately exits
- D
It waits indefinitely for a keyboard key press
Correct answer
DIt waits indefinitely for a keyboard key press
Explanation
cv.waitKeywaits for a specified delay in milliseconds; a delay of zero means it waits indefinitely for a key press. - A
- 13
What can the argument to
cv.VideoCapturerepresent?- A
Only the width and height of a video
- B
Only the name of an image window
- C
A camera index or a path to a video file
- D
A threshold and maximum pixel value
Correct answer
CA camera index or a path to a video file
Explanation
cv.VideoCaptureaccepts an integer camera index or a path to an existing video file. - A
- 14
Which camera is most commonly referenced by index
0?- A
The second external camera
- B
The computer's screen-capture device
- C
The computer's default webcam
- D
The first saved video file
Correct answer
CThe computer's default webcam
Explanation
Camera index
0commonly refers to the default webcam. Additional cameras may use indices such as1or2. - A
- 15
What does
capture.read()return when reading a video?- A
Only the video's filename and duration
- B
A threshold value and a binary mask
- C
The camera index and frame dimensions
- D
A success Boolean and the next video frame
Correct answer
DA success Boolean and the next video frame
Explanation
capture.read()returns a Boolean indicating success and the frame that was read. - A
- 16
Why is a loop commonly used when reading a video with OpenCV?
- A
Video is processed one frame at a time
- B
The loop changes the camera into a file path
- C
OpenCV can display only one pixel per loop
- D
Each video must be converted into a still image first
Correct answer
AVideo is processed one frame at a time
Explanation
Video reading uses a loop to retrieve and display successive frames individually.
- A
- 17
What action ends the video-reading process in the example?
- A
Reaching the first frame restarts the capture
- B
Pressing the letter
dcauses the loop to break - C
Pressing any number automatically saves the video
- D
Calling
imshowcloses every OpenCV window
Correct answer
BPressing the letter
dcauses the loop to breakExplanation
The example checks whether the pressed key corresponds to
d; if so, it breaks out of the loop. - A
- 18
What should be done with a video capture after it is no longer needed?
- A
Increase the capture resolution before exiting
- B
Convert the capture object into a grayscale image
- C
Pass the capture object to
cv.imread - D
Release the capture and destroy the OpenCV windows
Correct answer
DRelease the capture and destroy the OpenCV windows
Explanation
The example releases the capture device and destroys all windows after the loop ends.
- A
- 19
What does a negative OpenCV assertion error commonly indicate in the described examples?
- A
The image contains too many color channels
- B
The requested image has been automatically resized
- C
The computer has successfully finished processing the media
- D
OpenCV could not find or read the specified media
Correct answer
DOpenCV could not find or read the specified media
Explanation
The error commonly occurs when OpenCV cannot locate or read an image, video, or additional frame at the specified location.
- A
- 20
Why are large images often resized or rescaled before display or processing?
- A
To prevent OpenCV from reading any image data
- B
To add more pixel information to the image
- C
To reduce computational strain and processing requirements
- D
To guarantee that every image becomes a color image
Correct answer
CTo reduce computational strain and processing requirements
Explanation
Large media files contain more information and require more processing, so downscaling can reduce computational strain.
- A
- 21
How is a frame's width represented in the described NumPy shape indexing?
- A
By
frame.shape[2]only - B
By
frame.shape[0] - C
By
frame.shape[-1]only - D
By
frame.shape[1]
Correct answer
DBy
frame.shape[1]Explanation
In the described image representation,
frame.shape[1]is the width andframe.shape[0]is the height. - A
- 22
If an image is rescaled with a factor of 0.75, what happens to its dimensions?
- A
The dimensions remain unchanged while colors change
- B
Both width and height are multiplied by 0.75
- C
Only the width is multiplied by 0.75
- D
Both dimensions are divided by 0.75
Correct answer
BBoth width and height are multiplied by 0.75
Explanation
The rescaling function multiplies both the original width and height by the scale factor.
- A
- 23
Which interpolation method is used in the example for resizing?
- A
cv.INTER_NEAREST_ONLY - B
cv.INTER_AREA - C
cv.INTER_CHANNEL - D
cv.INTER_BINARY
Correct answer
Bcv.INTER_AREAExplanation
The example uses
cv.INTER_AREAas the interpolation method for resizing. - A
- 24
Why is downscaling generally preferred when changing a camera frame's resolution?
- A
Cameras can display only images with fewer than three channels
- B
A camera generally cannot capture beyond its maximum capability
- C
Upscaling automatically removes all image noise
- D
Downscaling always increases the camera's optical resolution
Correct answer
BA camera generally cannot capture beyond its maximum capability
Explanation
A camera that captures at a maximum resolution such as 720P generally cannot produce genuine 1080P output by software rescaling.
- A
- 25
What is the main limitation of the
capture.setresolution method described?- A
It can resize only images that are larger than a monitor
- B
It changes only the color channels of an image
- C
It works only on grayscale still images
- D
It is intended for live video rather than existing video files
Correct answer
DIt is intended for live video rather than existing video files
Explanation
The described resolution-changing method works for live video from a camera or webcam, not for already existing standalone video files.
- A
- 26
What does a blank image created with
np.zerosprovide for drawing?- A
A video stream connected to the default webcam
- B
A grayscale histogram of the source image
- C
A black canvas on which shapes or text can be drawn
- D
A fully white image containing detected contours
Correct answer
CA black canvas on which shapes or text can be drawn
Explanation
An array of zeros creates a black image that can serve as a blank canvas.
- A
- 27
Why does a blank drawing canvas need a shape such as 500×500×3 for a color image?
- A
The last dimension stores the image's filename and path
- B
The first dimension specifies the number of drawing commands
- C
The three dimensions represent three separate image files
- D
The three dimensions represent height, width, and color channels
Correct answer
DThe three dimensions represent height, width, and color channels
Explanation
A color image array uses dimensions for height, width, and the three color channels.
- A
- 28
What does assigning the color value (0,255,0) produce in OpenCV's BGR format?
- A
White
- B
Blue
- C
Green
- D
Red
Correct answer
CGreen
Explanation
OpenCV uses BGR ordering, so (0,255,0) represents green.
- A
- 29
What does a thickness of −1 mean when drawing a rectangle or circle?
- A
The shape is filled
- B
The border is one pixel wide
- C
The shape is invisible
- D
The shape is drawn only outside the image
Correct answer
AThe shape is filled
Explanation
A thickness of −1 instructs OpenCV to fill the rectangle or circle.
- A
- 30
Which function draws a rectangle in OpenCV?
- A
cv.box - B
cv.put_rectangle_text - C
cv.draw_square_only - D
cv.rectangle
Correct answer
Dcv.rectangleExplanation
The rectangle is drawn using
cv.rectangle, with corner points, color, and thickness supplied as arguments. - A
- 31
Which function draws a circle in OpenCV?
- A
cv.round_shape - B
cv.draw_arc_only - C
cv.put_circle_text - D
cv.circle
Correct answer
Dcv.circleExplanation
The circle is drawn using
cv.circle, which takes a center, radius, color, and thickness. - A
- 32
Which function draws a standalone line between two points?
- A
cv.line - B
cv.draw_edge_window - C
cv.segment_only - D
cv.connect_pixels_text
Correct answer
Acv.lineExplanation
OpenCV uses
cv.lineto draw a line between two specified points. - A
- 33
What does
cv.putTextrequire in order to place text on an image?- A
Text, an origin, a font, a scale, a color, and a thickness
- B
A camera index, a frame rate, and a threshold
- C
Only the text string and the image filename
- D
A contour list, a mask, and a histogram
Correct answer
AText, an origin, a font, a scale, a color, and a thickness
Explanation
cv.putTextuses the text, starting position, font face, font scale, color, and thickness to render text. - A
- 34
What is the primary visual difference between a BGR image and a grayscale image?
- A
BGR represents only intensity, while grayscale represents three colors
- B
BGR is binary, while grayscale always contains four channels
- C
BGR contains video frames, while grayscale contains only text
- D
BGR represents three color channels, while grayscale represents intensity
Correct answer
DBGR represents three color channels, while grayscale represents intensity
Explanation
A BGR image has blue, green, and red channels; a grayscale image represents pixel intensity without separate color channels.
- A
- 35
Which color-conversion code converts an OpenCV BGR image to grayscale?
- A
cv.COLOR_BGR2HSV - B
cv.COLOR_RGB2BGR - C
cv.COLOR_BGR2GRAY - D
cv.COLOR_GRAY2BGR
Correct answer
Ccv.COLOR_BGR2GRAYExplanation
cv.COLOR_BGR2GRAYconverts a BGR image into grayscale. - A
- 36
What is the main purpose of applying a blur to an image?
- A
To convert every pixel into a binary label
- B
To reduce noise and unwanted variations
- C
To guarantee that every edge becomes sharper
- D
To increase the number of color channels
Correct answer
BTo reduce noise and unwanted variations
Explanation
Blurring can reduce noise caused by poor lighting, camera sensors, or other unwanted image variations.
- A
- 37
What does the Canny edge detector attempt to identify?
- A
Edges and prominent intensity transitions
- B
The file format of a video
- C
The exact camera model used to capture an image
- D
The names of people in an image
Correct answer
AEdges and prominent intensity transitions
Explanation
Canny is an edge-detection algorithm that identifies edge-like transitions in an image.
- A
- 38
What generally happens to detected edges when an image is blurred before applying Canny?
- A
The Canny algorithm is replaced by a histogram
- B
Fewer edges are usually detected because noise is reduced
- C
The image gains additional color channels
- D
Every pixel becomes an edge regardless of its intensity
Correct answer
BFewer edges are usually detected because noise is reduced
Explanation
Blurring removes some noise and fine variations, often reducing the number of edges detected by Canny.
- A
- 39
What does dilation do to detected edges?
- A
It generally makes edge regions thicker
- B
It converts all edges into text labels
- C
It changes the image from BGR directly to HSV
- D
It always removes every edge from the image
Correct answer
AIt generally makes edge regions thicker
Explanation
Dilation expands foreground regions, so edge structures generally become thicker.
- A
- 40
What is the typical purpose of erosion after dilation?
- A
To shrink or thin the expanded structures
- B
To calculate the number of histogram bins
- C
To add a new color channel to the image
- D
To enlarge the image while preserving aspect ratio
Correct answer
ATo shrink or thin the expanded structures
Explanation
Erosion reduces foreground regions and can partially reverse the expansion caused by dilation.
- A
- 41
What does
cv.resizedo when given a destination size of 500×500?- A
It crops a 500×500 region without changing the original image
- B
It changes only the image's brightness to a value of 500
- C
It creates 500 separate copies of the image
- D
It resizes the image to that destination size, potentially changing its aspect ratio
Correct answer
DIt resizes the image to that destination size, potentially changing its aspect ratio
Explanation
The described call resizes the image to 500×500 and ignores the original aspect ratio unless dimensions are chosen accordingly.
- A
- 42
How does array slicing crop an image?
- A
It detects the external contours automatically
- B
It selects a range of rows and columns from the image array
- C
It changes every pixel to the average image intensity
- D
It removes only the image's color channels
Correct answer
BIt selects a range of rows and columns from the image array
Explanation
Because images are arrays, slicing row and column ranges selects a rectangular region of the image.
- A
- 43
What is translation in image processing?
- A
Shifting an image along the x-axis, the y-axis, or both
- B
Replacing each pixel with its median neighbor
- C
Rotating an image around its center
- D
Changing a color image into grayscale
Correct answer
AShifting an image along the x-axis, the y-axis, or both
Explanation
Translation shifts an image horizontally, vertically, or in both directions.
- A
- 44
What is the effect of a negative x translation value?
- A
The image shifts to the right
- B
The image rotates clockwise
- C
The image shifts downward
- D
The image shifts to the left
Correct answer
DThe image shifts to the left
Explanation
In the described translation convention, negative x values shift the image left.
- A
- 45
What is the effect of a positive y translation value?
- A
The image shifts downward
- B
The image shifts left
- C
The image flips horizontally
- D
The image shifts upward
Correct answer
AThe image shifts downward
Explanation
Positive y values shift the image downward, while negative y values shift it upward.
- A
- 46
Around which point does the rotation function rotate an image when no point is supplied?
- A
The upper-left corner only
- B
The center of the image
- C
The first detected contour
- D
The lower-right corner only
Correct answer
BThe center of the image
Explanation
When the rotation point is
None, the function uses the image center as the rotation point. - A
- 47
What is the effect of a negative rotation angle in the described convention?
- A
The image rotates clockwise
- B
The image becomes grayscale
- C
The image translates left
- D
The image rotates counterclockwise
Correct answer
AThe image rotates clockwise
Explanation
The example states that positive angles rotate counterclockwise and negative angles rotate clockwise.
- A
- 48
Why can black triangular regions appear after rotating an image?
- A
The image was automatically thresholded before rotation
- B
The rotation converts all blue pixels to black
- C
The rotated canvas contains areas with no source-image pixels
- D
The image's histogram has too few bins
Correct answer
CThe rotated canvas contains areas with no source-image pixels
Explanation
Rotating an image can expose canvas regions that are not covered by the original image; these regions default to black.
- A
- 49
What do the flip codes 0, 1, and −1 represent in the described OpenCV usage?
- A
0 flips vertically, 1 horizontally, and −1 both ways
- B
0 flips horizontally, 1 vertically, and −1 rotates
- C
0 rotates, 1 crops, and −1 resizes
- D
0 blurs, 1 thresholds, and −1 detects edges
Correct answer
A0 flips vertically, 1 horizontally, and −1 both ways
Explanation
The material specifies that 0 means vertical flipping, 1 means horizontal flipping, and −1 means both vertical and horizontal flipping.
- A
- 50
What is a contour?
- A
A numerical label assigned to a detected face
- B
A curve or line joining continuous points along an object's boundary
- C
A rectangular window used to compute a blur
- D
A list containing the colors used by a camera
Correct answer
BA curve or line joining continuous points along an object's boundary
Explanation
Contours represent object boundaries formed by curves or lines joining continuous boundary points.
- A
- 51
How do contours differ mathematically from edges?
- A
They are related boundary concepts but are not mathematically identical
- B
They are exactly the same operation under every definition
- C
Contours describe colors, while edges describe file paths
- D
Edges are always filled regions, while contours are always histograms
Correct answer
AThey are related boundary concepts but are not mathematically identical
Explanation
The content notes that contours and edges can be treated similarly in many programming contexts, but they are mathematically different.
- A
- 52
Which
findContoursretrieval mode returns all contours in the image without focusing only on external contours?- A
cv.RETR_EXTERNAL - B
cv.RETR_NONE - C
cv.RETR_LIST - D
cv.RETR_BINARY_ONLY
Correct answer
Ccv.RETR_LISTExplanation
cv.RETR_LISTreturns all contours.cv.RETR_EXTERNALreturns only external contours, whilecv.RETR_TREEpreserves hierarchical relationships. - A
- 53
What does
cv.RETR_EXTERNALretrieve?- A
Only the first contour found
- B
Every contour together with its pixel histogram
- C
Only the external contours
- D
Only contours nested inside other contours
Correct answer
COnly the external contours
Explanation
cv.RETR_EXTERNALretrieves only the outermost contours. - A
- 54
What does
cv.RETR_TREEpreserve?- A
The hierarchical relationships among contours
- B
The RGB values of every contour pixel
- C
The order in which video frames were captured
- D
The original camera exposure settings
Correct answer
AThe hierarchical relationships among contours
Explanation
cv.RETR_TREEreturns contours along with their hierarchical organization, such as nested shapes. - A
- 55
What is the purpose of
CHAIN_APPROX_SIMPLE?- A
To compress redundant contour points while preserving the essential shape
- B
To convert contours into grayscale images
- C
To retrieve only contours at the outermost level
- D
To increase the number of points along every contour
Correct answer
ATo compress redundant contour points while preserving the essential shape
Explanation
CHAIN_APPROX_SIMPLEcompresses contour representations, such as representing a straight line with its endpoints rather than every intermediate point. - A
- 56
What is a color space?
- A
A numerical ranking of image quality
- B
A list of all files in an image directory
- C
A system for representing pixel colors
- D
A method for detecting camera movement
Correct answer
CA system for representing pixel colors
Explanation
A color space is a system used to represent the colors of pixels.
- A
- 57
What does HSV stand for?
- A
Height, scale, and visibility
- B
Histogram, shape, and variance
- C
Horizontal, spatial, and vertical
- D
Hue, saturation, and value
Correct answer
DHue, saturation, and value
Explanation
HSV represents hue, saturation, and value and is described as a color space related to how humans conceive of color.
- A
- 58
Why can an OpenCV image appear to have inverted colors when displayed with Matplotlib?
- A
Matplotlib automatically thresholds every image
- B
OpenCV stores images using only grayscale intensities
- C
OpenCV uses BGR ordering while Matplotlib expects RGB ordering
- D
Matplotlib reverses the image vertically before display
Correct answer
COpenCV uses BGR ordering while Matplotlib expects RGB ordering
Explanation
OpenCV conventionally reads images as BGR, whereas Matplotlib interprets the channels as RGB, causing red and blue to appear swapped.
- A
- 59
Which conversion corrects an OpenCV BGR image for display as RGB in Matplotlib?
- A
cv.COLOR_RGB2GRAY - B
cv.COLOR_BGR2RGB - C
cv.COLOR_GRAY2BGR - D
cv.COLOR_BGR2HSV
Correct answer
Bcv.COLOR_BGR2RGBExplanation
cv.COLOR_BGR2RGBswaps the blue and red channel ordering so the image is correctly interpreted as RGB. - A
- 60
How can a grayscale image be converted to HSV according to the content?
- A
Convert grayscale directly to HSV with no intermediate step
- B
Convert grayscale to a contour hierarchy first
- C
Convert grayscale to RGB only after applying a histogram
- D
Convert grayscale to BGR first, then convert BGR to HSV
Correct answer
DConvert grayscale to BGR first, then convert BGR to HSV
Explanation
The material states that grayscale cannot be converted directly to HSV in the described workflow; it should first be converted to BGR.
- A
- 61
What does
cv.splitdo to a BGR image?- A
It divides the image into four equal spatial quadrants
- B
It separates the image into foreground and background masks
- C
It converts all channels into one histogram
- D
It separates the image into blue, green, and red channel arrays
Correct answer
DIt separates the image into blue, green, and red channel arrays
Explanation
cv.splitseparates a color image into its individual channel arrays. - A
- 62
Why are individual color-channel arrays displayed as grayscale images?
- A
OpenCV deletes the color information permanently during splitting
- B
Grayscale display means that the channel contains no pixel values
- C
Each channel is automatically converted into a contour
- D
Each channel is a one-channel intensity array
Correct answer
DEach channel is a one-channel intensity array
Explanation
A separated channel contains one intensity value per pixel, so OpenCV displays it as a grayscale image.
- A
- 63
What does
cv.mergedo?- A
It combines all contours into a single boundary
- B
It merges separate images by averaging their histograms
- C
It combines separate channel arrays into a multichannel image
- D
It joins multiple video files into one capture device
Correct answer
CIt combines separate channel arrays into a multichannel image
Explanation
cv.mergecombines individual color-channel arrays back into a multichannel image. - A
- 64
What is a blur kernel or window?
- A
A rectangle used only for drawing text
- B
A file containing the trained face-recognition model
- C
A neighborhood of pixels used to calculate a new pixel value
- D
A list of camera indices supported by OpenCV
Correct answer
CA neighborhood of pixels used to calculate a new pixel value
Explanation
A blur kernel is a window placed over an image; surrounding pixels in that window influence the computed center pixel.
- A
- 65
What does a kernel size of 3×3 specify?
- A
A three-pixel-wide border and a three-pixel radius
- B
A window containing three rows and three columns
- C
Three color channels and three video frames
- D
Three images with three histogram bins each
Correct answer
BA window containing three rows and three columns
Explanation
A 3×3 kernel has three rows and three columns of pixels.
- A
- 66
How does averaging blur calculate the new center pixel?
- A
It replaces the center pixel with a random channel value
- B
It assigns the center pixel the maximum possible intensity
- C
It uses the average of the surrounding pixel intensities
- D
It uses only the darkest surrounding pixel
Correct answer
CIt uses the average of the surrounding pixel intensities
Explanation
Averaging blur computes the center value from the average of the surrounding pixels in the kernel.
- A
- 67
What generally happens when the averaging-blur kernel increases from 3×3 to 7×7?
- A
The image is converted into a contour hierarchy
- B
The image becomes more blurred
- C
The image gains two additional color channels
- D
The image becomes automatically sharper
Correct answer
BThe image becomes more blurred
Explanation
A larger averaging window incorporates more neighboring pixels, generally producing stronger blur.
- A
- 68
How does Gaussian blur differ from simple averaging blur?
- A
Gaussian blur always produces more blur than every other method
- B
Gaussian blur uses no neighboring pixels at all
- C
Gaussian blur assigns different weights to neighboring pixels
- D
Gaussian blur changes only the image's width and height
Correct answer
CGaussian blur assigns different weights to neighboring pixels
Explanation
Gaussian blur weights neighboring pixels rather than treating all surrounding pixels equally.
- A
- 69
What is a typical characteristic of Gaussian blur compared with averaging blur?
- A
It always removes every edge from the image
- B
It requires a binary image rather than a color or grayscale image
- C
It replaces every pixel with the maximum intensity
- D
It often produces less abrupt and more natural-looking blur
Correct answer
DIt often produces less abrupt and more natural-looking blur
Explanation
The material describes Gaussian blur as more natural and generally less blurred than averaging for comparable kernel sizes.
- A
- 70
How does median blur determine the new center pixel?
- A
It uses the first pixel encountered in the kernel
- B
It uses the median of the neighboring pixel intensities
- C
It uses the weighted mean of all color channels
- D
It uses the minimum possible pixel value
Correct answer
BIt uses the median of the neighboring pixel intensities
Explanation
Median blur replaces the center value using the median of the surrounding values.
- A
- 71
For what type of noise is median blur especially useful?
- A
Salt-and-pepper noise
- B
Noise created by incorrect contour hierarchies
- C
Noise caused only by missing color channels
- D
Noise caused only by excessive image dimensions
Correct answer
ASalt-and-pepper noise
Explanation
Median blurring is described as effective for reducing salt-and-pepper noise and substantial image noise.
- A
- 72
What distinguishes bilateral filtering from traditional blurring methods?
- A
It uses only the farthest pixels from the center
- B
It removes all color information before filtering
- C
It converts every image into a binary mask
- D
It blurs while attempting to preserve edges
Correct answer
DIt blurs while attempting to preserve edges
Explanation
Bilateral filtering applies smoothing while retaining important image edges.
- A
- 73
What does a larger bilateral-filter spatial sigma imply?
- A
The image is automatically converted to grayscale
- B
Pixels farther from the center can influence the calculation
- C
The filter uses fewer neighboring pixels
- D
Only pixels with identical colors influence the calculation
Correct answer
BPixels farther from the center can influence the calculation
Explanation
A larger spatial sigma allows pixels farther away from the central pixel to affect the blur.
- A
- 74
What is the basic behavior of a bitwise AND between two binary images?
- A
It inverts every active and inactive pixel
- B
It preserves only regions active in exactly one image
- C
It preserves every region active in either image
- D
It preserves regions that are active in both images
Correct answer
DIt preserves regions that are active in both images
Explanation
Bitwise AND returns the intersection: pixels remain active only where both input images are active.
- A
- 75
What is the basic behavior of a bitwise OR between two binary images?
- A
It preserves only regions active in neither image
- B
It preserves only regions active in both images
- C
It preserves regions active in either or both images
- D
It reverses the colors of one input image
Correct answer
CIt preserves regions active in either or both images
Explanation
Bitwise OR combines active regions from both images, including their intersection.
- A
- 76
What is the basic behavior of a bitwise XOR between two binary images?
- A
It turns every pixel into its grayscale average
- B
It preserves every region regardless of activity
- C
It preserves regions active in both images
- D
It preserves regions active in exactly one of the images
Correct answer
DIt preserves regions active in exactly one of the images
Explanation
XOR returns the non-intersecting regions: pixels active in one input but not both.
- A
- 77
What does bitwise NOT do to a binary image?
- A
It inverts active and inactive pixel values
- B
It returns only the intersection with another image
- C
It removes all pixels outside the image center
- D
It averages the image with a second source image
Correct answer
AIt inverts active and inactive pixel values
Explanation
Bitwise NOT changes active pixels to inactive and inactive pixels to active.
- A
- 78
What is the purpose of masking in image processing?
- A
To replace all image colors with grayscale
- B
To increase the resolution of every image
- C
To identify the camera that captured the image
- D
To focus processing on selected regions of an image
Correct answer
DTo focus processing on selected regions of an image
Explanation
Masking isolates selected portions of an image so unwanted regions can be ignored.
- A
- 79
What requirement must a mask satisfy when used with an image in the described operation?
- A
The mask must have the same dimensions as the image
- B
The mask must be a text file rather than an array
- C
The mask must contain three more channels than the image
- D
The mask must always be twice as large as the image
Correct answer
AThe mask must have the same dimensions as the image
Explanation
The material emphasizes that a mask must have the same dimensions as the image or the operation will fail.
- A
- 80
How is the masked image produced in the example?
- A
By applying bitwise XOR to the image filename
- B
By applying a bitwise AND between the source image and the mask
- C
By adding the source image to its histogram
- D
By rotating the source image around the mask center
Correct answer
BBy applying a bitwise AND between the source image and the mask
Explanation
The masked image is produced with a bitwise AND operation using the source image and a mask.
- A
- 81
What does an image histogram visualize?
- A
The number of cameras connected to a computer
- B
The geometric center of every detected face
- C
The order of contours in an image
- D
The distribution of pixel intensities
Correct answer
DThe distribution of pixel intensities
Explanation
A histogram plots how frequently different pixel-intensity values occur.
- A
- 82
What does the horizontal axis of the described grayscale histogram represent?
- A
The image's color-channel names
- B
The sequence of video frames
- C
Pixel-intensity intervals or bins
- D
The number of image rows
Correct answer
CPixel-intensity intervals or bins
Explanation
The histogram's horizontal axis represents bins covering possible pixel intensities, from 0 through 255.
- A
- 83
What does the vertical axis of the described histogram represent?
- A
The width of the image in pixels
- B
The number of contours detected per frame
- C
The number of pixels in each intensity bin
- D
The number of color channels in each pixel
Correct answer
CThe number of pixels in each intensity bin
Explanation
The vertical axis shows how many pixels have intensities within each bin.
- A
- 84
How is a color histogram different from a grayscale histogram?
- A
It contains no pixel-intensity information
- B
It can represent separate distributions for the blue, green, and red channels
- C
It always has exactly one bin
- D
It can be computed only from binary masks
Correct answer
BIt can represent separate distributions for the blue, green, and red channels
Explanation
A color histogram can plot intensity distributions separately for each color channel.
- A
- 85
What is the purpose of computing a histogram with a mask?
- A
To analyze pixel intensities only within a selected region
- B
To convert all image channels into contours
- C
To determine the camera index used for capture
- D
To increase the total number of pixels in the image
Correct answer
ATo analyze pixel intensities only within a selected region
Explanation
A mask restricts histogram computation to the selected part of the image.
- A
- 86
What does simple thresholding do when a pixel intensity is below the threshold?
- A
It replaces the pixel with its neighborhood median
- B
It marks the pixel as a detected face
- C
It sets the pixel to the maximum value
- D
It sets the pixel to zero or black
Correct answer
DIt sets the pixel to zero or black
Explanation
In the described binary thresholding rule, values below the threshold become zero.
- A
- 87
What does simple binary thresholding do when a pixel intensity is above the threshold?
- A
It changes the pixel into a camera index
- B
It sets the pixel to the selected maximum value, such as 255
- C
It always sets the pixel to zero
- D
It replaces the pixel with a contour coordinate
Correct answer
BIt sets the pixel to the selected maximum value, such as 255
Explanation
Pixels above the threshold are assigned the maximum value, typically 255 for a white binary pixel.
- A
- 88
What is the main limitation of simple thresholding?
- A
The threshold value must be manually specified
- B
It automatically changes the image dimensions
- C
It cannot produce binary images
- D
It requires a video rather than an image
Correct answer
AThe threshold value must be manually specified
Explanation
Simple thresholding depends on a manually chosen threshold value, which may not work well across varying image regions.
- A
- 89
How does inverse binary thresholding differ from ordinary binary thresholding?
- A
It assigns the maximum value to pixels below the threshold instead
- B
It computes a median instead of comparing intensities
- C
It assigns zero to every pixel regardless of intensity
- D
It changes only the image's width and height
Correct answer
AIt assigns the maximum value to pixels below the threshold instead
Explanation
Inverse thresholding reverses the usual mapping: pixels below the threshold become white and pixels above it become black.
- A
- 90
What is the central idea of adaptive thresholding?
- A
The threshold is determined by the camera index
- B
The threshold is always set to exactly 255
- C
The threshold is replaced by a contour hierarchy
- D
The threshold is computed locally rather than fixed for the entire image
Correct answer
DThe threshold is computed locally rather than fixed for the entire image
Explanation
Adaptive thresholding determines threshold values from local neighborhoods, allowing different image regions to use different thresholds.
- A
- 91
What does the block size represent in adaptive thresholding?
- A
The number of cameras used to capture the image
- B
The total number of color channels in the image
- C
The number of output classes in a neural network
- D
The neighborhood used to compute a local threshold
Correct answer
DThe neighborhood used to compute a local threshold
Explanation
The block size specifies the local neighborhood or window used to calculate the adaptive threshold.
- A
- 92
How does Gaussian adaptive thresholding differ from mean adaptive thresholding?
- A
It ignores the local neighborhood entirely
- B
It uses weighted neighborhood values when computing the local threshold
- C
It converts the image directly into a color histogram
- D
It always uses a manually fixed global threshold
Correct answer
BIt uses weighted neighborhood values when computing the local threshold
Explanation
Gaussian adaptive thresholding applies weights to neighborhood pixels, unlike the simple mean method.
- A
- 93
How do gradients relate to edges in the course's programming discussion?
- A
Edges are calculated only from histograms, never gradients
- B
They can be treated as edge-like regions, although they are mathematically different
- C
They are mathematically identical in every context
- D
Gradients refer only to color channels, never boundaries
Correct answer
BThey can be treated as edge-like regions, although they are mathematically different
Explanation
The content distinguishes gradients and edges mathematically but notes that gradients can be treated as edge-like regions in programming contexts.
- A
- 94
What does the Laplacian method compute?
- A
The average color of every detected face
- B
The number of bins in a color histogram
- C
Image gradients using second-derivative information
- D
The dimensions of the camera sensor
Correct answer
CImage gradients using second-derivative information
Explanation
The Laplacian method computes gradient information in the grayscale image and highlights edge-like transitions.
- A
- 95
Why is the absolute value taken after computing Laplacian gradients?
- A
Negative values indicate that the image was not resized
- B
Image pixel values cannot represent negative intensities
- C
The absolute value converts every image into HSV
- D
Absolute values create additional color channels
Correct answer
BImage pixel values cannot represent negative intensities
Explanation
Gradient calculations can produce negative values, but image intensities cannot be negative, so absolute values are used before converting to an image datatype.
- A
- 96
In which directions does the Sobel method compute gradients in the example?
- A
Along the time direction of a video
- B
Only along the diagonal direction
- C
Along the x and y directions
- D
Only along the color-channel direction
Correct answer
CAlong the x and y directions
Explanation
Sobel computes separate gradient images in the x and y directions.
- A
- 97
How are the Sobel x and Sobel y results combined in the example?
- A
By applying inverse thresholding to only the x result
- B
By replacing both with the original BGR image
- C
By multiplying their filenames
- D
With a bitwise OR operation
Correct answer
DWith a bitwise OR operation
Explanation
The two Sobel gradient images are combined using a bitwise OR operation.
- A
- 98
Why is Canny often preferred for cleaner edge detection in the described comparison?
- A
It automatically identifies the names of objects
- B
It is a multistage algorithm designed to produce cleaner edge results
- C
It does not use any intensity information
- D
It works only on images with no noise
Correct answer
BIt is a multistage algorithm designed to produce cleaner edge results
Explanation
Canny is described as a more advanced multistage edge detector that often produces cleaner edges than the basic Laplacian or Sobel results.
- A
- 99
What is the difference between face detection and face recognition?
- A
Detection finds whether a face is present; recognition identifies whose face it is
- B
Detection requires labels; recognition never uses image data
- C
Detection and recognition are identical terms for the same task
- D
Detection identifies a person; recognition only changes image brightness
Correct answer
ADetection finds whether a face is present; recognition identifies whose face it is
Explanation
Face detection locates or confirms faces, whereas face recognition attempts to identify the person associated with a face.
- A
- 100
What does a classifier do in face detection?
- A
It converts all face images into histograms
- B
It resizes every detected face to the same dimensions
- C
It decides whether an image region is positive or negative for a face
- D
It records the camera's maximum resolution
Correct answer
CIt decides whether an image region is positive or negative for a face
Explanation
A classifier determines whether a given image region contains a face or does not contain a face.
- A
- 101
What type of training data does a face classifier require?
- A
Only video filenames and camera indices
- B
Only blank images with no objects
- C
Only one image of each person
- D
Many images both with faces and without faces
Correct answer
DMany images both with faces and without faces
Explanation
Classifiers must be trained on many positive examples containing faces and negative examples without faces.
- A
- 102
What is a Haar cascade in the described OpenCV workflow?
- A
A NumPy array used only for drawing rectangles
- B
A pretrained classifier that can detect visual objects such as faces
- C
A histogram equalization method for grayscale images
- D
A color-space conversion between BGR and HSV
Correct answer
BA pretrained classifier that can detect visual objects such as faces
Explanation
Haar cascades are pretrained classifiers supplied for detecting objects, including frontal faces.
- A
- 103
How are local binary pattern classifiers described relative to Haar cascades?
- A
They are identical to simple global thresholding
- B
They are used only to resize video frames
- C
They are described as unable to detect faces
- D
They are described as more advanced and less prone to image noise
Correct answer
DThey are described as more advanced and less prone to image noise
Explanation
The content describes local binary pattern classifiers as more advanced and less sensitive to noise than Haar cascades.
- A
- 104
Why is a face image converted to grayscale before Haar-cascade detection?
- A
Grayscale images contain more color information than BGR images
- B
The classifier relies mainly on structural edges rather than skin color
- C
Haar cascades require three color channels for every detection
- D
Converting to grayscale automatically identifies the person's name
Correct answer
BThe classifier relies mainly on structural edges rather than skin color
Explanation
The described detection method focuses on object structure and edges, so color information is unnecessary.
- A
- 105
What does
detectMultiScalereturn in the face-detection example?- A
A single string containing the person's identity
- B
A histogram for every color channel
- C
A list of all pixels that were converted to grayscale
- D
Rectangular coordinates for detected face regions
Correct answer
DRectangular coordinates for detected face regions
Explanation
detectMultiScalereturns rectangular regions represented by coordinates such as x, y, width, and height. - A
- 106
What does the minimum-neighbors parameter influence in Haar-cascade detection?
- A
The number of pixels used in a Gaussian kernel
- B
The number of color channels in the source image
- C
The maximum width of the video frame
- D
How many neighboring detections support calling a region a face
Correct answer
DHow many neighboring detections support calling a region a face
Explanation
Minimum neighbors specifies how much neighboring detection support is required before a candidate region is accepted as a face.
- A
- 107
What trade-off results from increasing the minimum-neighbors value?
- A
The video frame rate increases while every face is guaranteed to be found
- B
All faces become colored, but no rectangles are drawn
- C
The image becomes larger, but the classifier stops using edges
- D
Fewer false detections may occur, but some real faces may be missed
Correct answer
DFewer false detections may occur, but some real faces may be missed
Explanation
Increasing minimum neighbors makes detection stricter, which can reduce noise and false positives but may lower sensitivity.
- A
- 108
Why might a Haar cascade detect a stomach or neck as a face?
- A
The grayscale conversion labels all body parts as faces
- B
The classifier recognizes every bright pixel as a face
- C
Haar cascades can be sensitive to image noise and face-like structures
- D
The detection function searches only for circular objects
Correct answer
CHaar cascades can be sensitive to image noise and face-like structures
Explanation
Haar cascades can produce false positives when non-face regions contain structures that resemble the learned face patterns.
- A
- 109
What is the first major step when training the built-in face recognizer?
- A
Collect face image arrays and their corresponding labels
- B
Draw a circle around every pixel
- C
Convert every label into a histogram bin
- D
Delete all images without changing the model
Correct answer
ACollect face image arrays and their corresponding labels
Explanation
The workflow builds a feature list containing face arrays and a label list identifying the person associated with each face.
- A
- 110
Why are person names converted into numerical labels?
- A
The labels determine the camera's resolution
- B
Numerical labels add color information to grayscale faces
- C
Names cannot be stored in any Python data structure
- D
A numerical mapping makes the training representation easier for the model to use
Correct answer
DA numerical mapping makes the training representation easier for the model to use
Explanation
Each person's name is mapped to a numerical index, such as the person's position in the people list, for model training.
- A
- 111
What does the built-in face recognizer's
trainmethod use?- A
Only the Haar cascade XML text
- B
A histogram without any face-image data
- C
The feature arrays and their corresponding numerical labels
- D
Only the filenames of the training images
Correct answer
CThe feature arrays and their corresponding numerical labels
Explanation
Training uses the extracted face arrays as features and the associated numerical labels as targets.
- A
- 112
Why is the trained face-recognition model saved to a YAML file?
- A
YAML files automatically improve the model's accuracy
- B
It can be loaded later without repeating the entire training process
- C
YAML files convert face images into RGB format
- D
Saving to YAML removes the need for any training images
Correct answer
BIt can be loaded later without repeating the entire training process
Explanation
Saving the trained model allows it to be reused in another program or directory without rebuilding and retraining it.
- A
- 113
What does the face recognizer's
predictoperation produce?- A
The original image in a different color space
- B
A predicted numerical label and a confidence-related value
- C
A new training set containing unlabeled images
- D
Only the coordinates of every image contour
Correct answer
BA predicted numerical label and a confidence-related value
Explanation
The recognizer predicts a label for the face region and returns a confidence-related value.
- A
- 114
Why can the built-in face recognizer produce unreliable predictions in the example?
- A
It was trained only on color histograms rather than faces
- B
It cannot process grayscale images at all
- C
It was trained on a relatively small dataset and is not the most advanced model
- D
It always predicts the first person alphabetically
Correct answer
CIt was trained on a relatively small dataset and is not the most advanced model
Explanation
The example uses only about 100 training images and the built-in recognizer is less robust than more advanced deep-learning approaches.
- A
- 115
What is a key advantage of a deep-learning model for image classification?
- A
It eliminates the need to resize input images
- B
It guarantees perfect accuracy with ten images
- C
It requires no training data or validation data
- D
It can learn complex visual patterns from large training datasets
Correct answer
DIt can learn complex visual patterns from large training datasets
Explanation
Deep-learning models are powerful because they can learn complex visual features, especially when trained with substantial data.
- A
- 116
Why is a GPU useful when training a deep computer-vision model?
- A
It converts all images into grayscale without preprocessing
- B
It automatically labels every image correctly
- C
It replaces the need for a neural-network architecture
- D
It can accelerate the computationally intensive training process
Correct answer
DIt can accelerate the computationally intensive training process
Explanation
A GPU, or graphical processing unit, can significantly speed up neural-network training computations.
- A
- 117
Why must images in a dataset generally be resized before entering a neural network?
- A
Different image sizes automatically prevent grayscale conversion
- B
Resizing changes every image into a binary mask
- C
The model expects inputs with consistent dimensions
- D
Resizing is required to create Haar-cascade XML files
Correct answer
CThe model expects inputs with consistent dimensions
Explanation
Neural networks generally require all input images to have the same dimensions, such as 80×80.
- A
- 118
What does setting the image channel count to 1 indicate in the model setup?
- A
The model uses grayscale images
- B
The model has one convolutional layer
- C
The model uses one image per training class
- D
The model detects only one face in every image
Correct answer
AThe model uses grayscale images
Explanation
A single image channel indicates grayscale input rather than a three-channel color image.
- A
- 119
Why are the top ten character folders selected in the Simpsons example?
- A
They are the only folders containing grayscale images
- B
They contain only images without any characters
- C
They are selected randomly regardless of image count
- D
They provide the ten classes with the largest numbers of available images
Correct answer
DThey provide the ten classes with the largest numbers of available images
Explanation
The workflow counts images in each character folder, sorts the folders by count, and selects the first ten.
- A
- 120
What is the purpose of splitting data into training and validation sets?
- A
The model trains on one portion and evaluates itself on another
- B
The split converts all images into two color channels
- C
The split ensures that every image is used only for visualization
- D
The split removes the need for labels
Correct answer
AThe model trains on one portion and evaluates itself on another
Explanation
Training data is used to fit the model, while validation data provides a separate evaluation during training.
- A
- 121
If the validation ratio is 0.2, how is the dataset divided in the described workflow?
- A
Approximately 80% is used for training and 20% for validation
- B
Half is used for training and half for validation
- C
All data is used for training and none for validation
- D
Approximately 20% is used for training and 80% for validation
Correct answer
AApproximately 80% is used for training and 20% for validation
Explanation
A validation ratio of 0.2 assigns about 20% of the data to validation and the remaining 80% to training.
- A
- 122
What does normalization do to the feature values in the described model pipeline?
- A
It scales the feature values into the range from 0 to 1
- B
It changes grayscale images into three-channel images
- C
It converts every feature into a class name
- D
It removes all labels from the training data
Correct answer
AIt scales the feature values into the range from 0 to 1
Explanation
The feature arrays are normalized so their values lie in the range [0,1], which can help the network learn more effectively.
- A
- 123
What does one-hot encoding do to class labels?
- A
It converts a model into a Haar cascade
- B
It removes the need to specify the number of classes
- C
It converts integer labels into binary class vectors
- D
It converts binary images into color images
Correct answer
CIt converts integer labels into binary class vectors
Explanation
One-hot encoding represents each class as a binary vector with one active class position.
- A
- 124
What is the purpose of an image data generator?
- A
To replace validation data with test filenames
- B
To synthesize variations of existing images and introduce training randomness
- C
To calculate only the grayscale histogram
- D
To detect faces without using any trained model
Correct answer
BTo synthesize variations of existing images and introduce training randomness
Explanation
An image data generator creates modified variations of existing images, which can improve training by introducing additional variation.
- A
- 125
What does the batch size specify during model training?
- A
The number of classes removed from the dataset
- B
The number of color channels in each image
- C
The number of samples processed together in one training step
- D
The number of validation sets created per image
Correct answer
CThe number of samples processed together in one training step
Explanation
The batch size determines how many examples are processed together during each training update.
- A
- 126
What is the purpose of a learning-rate schedule?
- A
To assign names to detected faces
- B
To resize images at fixed spatial intervals
- C
To determine the number of histogram bins
- D
To adjust the learning rate during training
Correct answer
DTo adjust the learning rate during training
Explanation
A learning-rate schedule changes the learning rate at selected stages to support model optimization.
- A
- 127
Why is a separate preparation function used before classifying a new image?
- A
It converts the trained model back into a YAML file
- B
It removes the need to use OpenCV for reading the image
- C
It ensures the new image has the same grayscale, size, and shape format as training inputs
- D
It guarantees that the model will predict the correct class
Correct answer
CIt ensures the new image has the same grayscale, size, and shape format as training inputs
Explanation
The preparation function converts the image to grayscale, resizes it, and reshapes it to match the format used during training.
- A
- 128
Why can a model with a stated accuracy near 70% still make visibly incorrect predictions?
- A
Accuracy values below 100% mean the model cannot make predictions
- B
Accuracy summarizes performance overall and does not guarantee correctness on every image
- C
A validation accuracy of 70% means exactly 70% of every image is correct
- D
A model's accuracy applies only to image dimensions, not classifications
Correct answer
BAccuracy summarizes performance overall and does not guarantee correctness on every image
Explanation
Overall accuracy is an aggregate metric; individual predictions may still be wrong even when the model performs reasonably on average.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.