Download Image Processing - Introduction to Computer Graphics - Lecture Slides and more Slides Computer Graphics in PDF only on Docsity!
Lecture 03:
Image Processing
What does “image” mean for us?
- A 2D domain with samples at regular points (almost always a rectilinear grid) - Can have multiple samples per point - Meaning of samples depend on the application (red, green, blue, opacity, depth, etc.)
- Units also depend on the application - e.g., an int or float to be mapped to voltage needed for display on a screen (e.g. a BMP file) - e.g., as a physical measurement of incoming light (e.g., a camera sensor)
The alpha channel
- In addition to the R, G, and
B channels of an image, add
a fourth channel called α
- Alpha varies between 0 and
- Value of 1 represents a completely opaque pixel, one you cannot see through
- Value of 0 is a completely transparent pixel
- Useful for blending images
- Images with higher alpha values are less transparent
The red box is drawn on top of the blue box using = 0.
Modeling an image
- Model a one-channel 𝑛 × 𝑘 image as the function 𝑢 𝑖, 𝑗
from pairs of integers to real numbers
- 𝑖 and 𝑗 are integers such that 0 ≤ 𝑖 < 𝑛 and 0 ≤ 𝑗 < 𝑘
- Associate each pixel value 𝑢 𝑖, 𝑗 to
small area around display location with coordinates 𝑖, 𝑗
- Image extends from −0.5, −0. to (𝑛 − 0.5, 𝑘 − 0.5)
- A pixel here looks like a square centered
over the sample point, but it’s just a value and the actual geometry of its screen appearance varies by device
- Roughly circular spot on CRT
- Rectangular on LCD panel
The Five Stages of Image Processing
skipped
often interlaced
Stage 1: Image Acquisition
- Image Synthesis
- Images created by a computer
- Painted in 2D
- Rendered from 3D geometry - Pixar’s RenderMan - Autodesk’s Maya - Your CS123 projects
- Procedurally textured
- Generated images intended to mimic their natural counterparts
- E.g. procedural wood grain
- Image Capture
- Images from the “real world”
- Information must be digitized from an analog signal
- Common capture methods:
- Digital camera
- Satellite data
- Drum scanner
- Flatbed photo scanner
- Frames from video
Stage 2: Preprocessing cont.
- Preprocessing techniques include:
- Adjusting color or grayscale curve
- Cropping
- Masking (cutting out part of an image)
- Scaling up (super sampling) or scaling down (sub sampling)
- Blurring and sharpening
- Edge detection/enhancement
- Filtering and antialiasing
- Notes:
- Blurring, sharpening, and edge detection can also be postprocessing techniques
- Some preprocessing algorithms are not followed by mapping, others that involve resampling the image may be interlaced with mapping: filtering is done this way
Stage 3: Mapping
- Mapping is a catch-all stage where several images are combined, or geometric transformations are applied
- Transformations include:
- Rotating
- Scaling
- Shearing
- Warping
- Feature-based morphing
- Compositing:
- Basic image overlay
- Smooth blending with alpha channels
- Poisson image blending
- Seamlessly transfers “details” (like edges) from part of one image to another Poisson Image Blending
Image Warping
Image credit: © Evan Wallace 2010
Stage 5: Output (Archive/Display)
- Choice of display/archive method may affect earlier
processing stages
- Color printing accentuates certain colors more than others
- Colors on the monitor have different gamuts and HSV values than the colors printed out - Need a mapping
- Display Technologies
- Monitors
- Color printers
- Film/videotapes
- Disk files
- Texture maps for 3D renderer
Close-up of an LCD screen
Jaggies & Aliasing
- “Jaggies” an informal name for artifacts from poorly representing geometry by a 2D grid of pixels - Jaggies are a manifestation of sampling error and loss of information (aliasing)
- Effect of jaggies can be reduced by anti-aliasing, which smoothes out the pixels around the jaggies - Shades of gray instead of sharp black/white transitions - Diminishes HVS’ response to sharp transitions (Mach banding)
Representing lines: Point sampling,
single pixel
- Midpoint algorithm: in each column, pick
the pixel with the closest center to the line
- A form of point sampling: sample the line at each of the integer X values
- Pick a single pixel to represent the line’s intensity, full on or full off
- Doubling resolution in x and y only lessens
the problem, but costs 4 times memory,
bandwidth, and scan conversion time!
- Note: This works for -1 < slope < 1, use rows instead of columns for the other case or there will be gaps in the line
Approximating same line at 2x the resolution
Line approximation using point sampling
Representing lines: Area sampling
- Represent the line as a unit width rectangle, use multiple pixels overlapping the rectangle (for now we think of pixels as squares)
- Instead of full on/off, calculate each pixel intensity proportional to the area covered by the unit rectangle
- A form of unweighted area sampling:
- Only pixels covered by primitive can contribute
- Distance of pixel center to line doesn’t matter
- Typically have more than one pixel per column
“Cone Filter” for Weighted Area
Sampling
- Area sampling, but the overlap between
filter and primitive is weighted so that sub- areas with 𝑑𝐴 closer to center of pixel count more
- Cone has:
- Linear falloff
- Circular symmetry
- Width of 2 (called “support”)
- Volume of 1 (this makes completely covered pixels have value 1)
- Intensity of pixel is the “subvolume” inside
the cone over the line (see picture)
Weighted Area Sampling Continued
W (𝑥, 𝑦) is the weight which is multiplied with 𝑑𝐴 at (𝑥, 𝑦) ; normalize W to make volume under cone = 1
2-unit circular^ W support of filter
Pixel center (+)
Area of overlap between support and primitive
Differential area dA 2 Primitive
Differential area dA 1