Computer Vision L2 - BSC
Computer Vision L2 - BSC
Color Models
Lecture Overview
• Understand how digital images are represented using
pixels and matrices.
• Explore various color models including RGB, grayscale,
HSV.
• Perform basic image operations using OpenCV: reading,
displaying, converting images.
THEORETICAL FOUNDATIONS
What is a Digital Image?
• A digital image is a representation of a visual scene stored as a
discrete grid of pixels (picture elements), each containing a
value or set of values that represent the brightness and/or
color at that point.
• Mathematical Definition:
A digital image can be viewed as a 2D function:
ƒ (x, y)
• where x and y are spatial coordinates, and ff represents the
intensity (for grayscale) or a vector of intensities (for color
images).
• For grayscale: f(x,y)∈[0,255]
• For color: f(x,y)=[R,G,B], each ∈[0,255]
Image Resolution
• Resolution refers to the number of pixels in the image
along the width and height dimensions.
• Resolution=Width×Height
• E.g., an image with resolution 1920×1080 contains
2,073,600 pixels.
• High Resolution: More details, larger file size.
• Low Resolution: Less detail, faster processing, smaller
file.
• Aspect Ratio: Proportion of width to height (e.g., 16:9,
4:3).
Image Channels
• Color models define the way colors are represented in
digital images.
• # Display image
• cv2.imshow('Original Image', img)
• cv2.waitKey(0)
• cv2.destroyAllWindows()
Coverting to Graycale
• gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
• cv2.imshow('Grayscale Image', gray_img)
• cv2.waitKey(0)
• cv2.destroyAllWindows()
Extracting Invidul Channels
• blue, green, red = cv2.split(img)