Digital Image Representation
Understand how images are stored and represented in digital form, including sampling and quantization.
Pixels
Sampling
Quantization
A digital image is a 2D array of pixels, where each pixel represents the intensity or color at a specific location. The process involves spatial sampling (determining pixel locations) and amplitude quantization (determining intensity levels).
# Digital Image Representation
image_representation = {
"definition": "2D function f(x,y) where x,y are spatial coordinates",
"digitization": {
"sampling": "Convert continuous spatial coordinates to discrete grid",
"quantization": "Convert continuous intensity values to discrete levels",
"result": "M x N array of integer values"
},
"pixel_properties": {
"grayscale": "Single intensity value (0-255 for 8-bit)",
"color": "Multiple channels (RGB, HSV, etc.)",
"bit_depth": "Number of bits per pixel (1, 8, 16, 32)",
"dynamic_range": "Ratio between maximum and minimum intensity"
},
"resolution_types": {
"spatial": "Number of pixels in image (width x height)",
"intensity": "Number of gray levels (2^bit_depth)",
"temporal": "Frame rate for video sequences"
}
}
Color Spaces and Models
Explore different ways to represent and manipulate color information in digital images.
Common Color Spaces:
• RGB: Red, Green, Blue - additive color model
• HSV: Hue, Saturation, Value - intuitive for humans
• LAB: Lightness, A, B - perceptually uniform
• YUV: Luminance and chrominance - used in video
• CMYK: Cyan, Magenta, Yellow, Black - printing
Color Space Conversion:
Converting between color spaces involves mathematical transformations. RGB to grayscale: Gray = 0.299*R + 0.587*G + 0.114*B (weighted sum based on human perception).
# Color Space Analysis
color_spaces = {
"rgb": {
"description": "Red, Green, Blue channels",
"range": "0-255 for each channel (8-bit)",
"advantages": ["Hardware-oriented", "Simple operations"],
"disadvantages": ["Not perceptually uniform", "Poor for color-based segmentation"]
},
"hsv": {
"description": "Hue (0-360°), Saturation (0-100%), Value (0-100%)",
"advantages": ["Intuitive", "Good for color filtering", "Separates color from intensity"],
"applications": ["Color-based object detection", "Skin detection", "Image enhancement"]
},
"lab": {
"description": "L* (lightness), a* (green-red), b* (blue-yellow)",
"advantages": ["Perceptually uniform", "Device-independent"],
"applications": ["Color correction", "Quality assessment", "Medical imaging"]
}
}
Pixel Operations
Learn fundamental operations that can be performed on individual pixels and their neighborhoods.
Types of Pixel Operations:
• Point operations: Transform individual pixels independently
• Local operations: Use neighborhood information
• Global operations: Use entire image statistics
• Geometric operations: Change spatial relationships
Operation Complexity:
Point operations are O(N) where N is number of pixels. Local operations are O(N×k) where k is neighborhood size. Choose efficiently based on requirements.
# Pixel Operations Categories
pixel_operations = {
"point_operations": {
"definition": "Output pixel depends only on input pixel at same location",
"examples": {
"brightness": "g(x,y) = f(x,y) + c",
"contrast": "g(x,y) = a * f(x,y)",
"gamma_correction": "g(x,y) = c * f(x,y)^γ",
"thresholding": "g(x,y) = 255 if f(x,y) > T else 0"
},
"complexity": "O(width × height)"
},
"neighborhood_operations": {
"definition": "Output depends on input pixel and its neighbors",
"examples": ["Convolution",