CSE559A Lecture 5
Continue on linear interpolation
- In linear interpolation, extreme values are at the boundary.
- In bicubic interpolation, extreme values may be inside.
scipy.interpolate.RegularGridInterpolator
Image transformations
Image warping is a process of applying transformation to an image.
Parametric (global) warping:
Geometric transformation: This applies to each pixel in the same way. (global)
Translation
matrix form:
Scaling
matrix form:
Rotation
matrix form:
To undo the rotation, we need to rotate the image by . This is equivalent to apply to the image.
Affine transformation
matrix form:
Taking all the transformations together.
Projective homography
Image warping
Forward warping
Send each pixel to its new position and do the matching.
- May cause gaps where the pixel is not mapped to any pixel.
Inverse warping
Send each new position to its original position and do the matching.
- Some mapping may not be invertible.
Which one is better?
- Inverse warping is better because it usually more efficient, doesn’t have a problem with holes.
- However, it may not always be possible to find the inverse mapping.
Sampling and Aliasing
Naive sampling
- Remove half of the rows and columns in the image.
Example:
When sampling a sine wave, the result may interpret as different wave.
Nyquist-Shannon sampling theorem
-
A bandlimited signal can be uniquely determined by its samples if the sampling rate is greater than twice the maximum frequency of the signal.
-
If the sampling rate is less than twice the maximum frequency of the signal, the signal will be aliased.
Anti-aliasing
- Sample more frequently. (not always possible)
- Get rid of all frequencies that are greater than half of the new sampling frequency.
- Use a low-pass filter to get rid of all frequencies that are greater than half of the new sampling frequency. (eg, Gaussian filter)
import scipy.ndimage as ndimage
def down_sample(height, width, image):
# Apply Gaussian blur to the image
im_blur = ndimage.gaussian_filter(image, sigma=1)
# Down sample the image by taking every second pixel
return im_blur[::2, ::2]Nonlinear filtering
Median filter
Replace the value of a pixel with the median value of its neighbors.
- Good for removing salt and pepper noise. (black and white dot noise)
Morphological operations
Binary image: image with only 0 and 1.
Let be a structuring element and be the original image (binary image).
- Erosion: , this is the set of all points that are completely covered by .
- Dilation: , this is the set of all points that are at least partially covered by .
- Opening: , this is the set of all points that are at least partially covered by after erosion.
- Closing: , this is the set of all points that are completely covered by after dilation.
Boundary extraction: use XOR operation on eroded image and original image.
Connected component labeling: label the connected components in the image. use prebuild function in scipy.ndimage
Light,Camera/Eyes, and Color
Principles of grouping and Gestalt Laws
- Proximity: objects that are close to each other are more likely to be grouped together.
- Similarity: objects that are similar are more likely to be grouped together.
- Closure: objects that form a closed path are more likely to be grouped together.
- Continuity: objects that form a continuous path are more likely to be grouped together.
Light and surface interactions
A photon’s life choices:
- Absorption
- Diffuse reflection (nice to model) (lambertian surface)
- Specular reflection (mirror-like) (perfect mirror)
- Transparency
- Refraction
- Fluorescence (returns different color)
- Subsurface scattering (candles)
- Photosphorescence
- Interreflection
BRDF (Bidirectional Reflectance Distribution Function)
- is the angle of incidence.
- is the azimuthal angle of incidence.
- is the angle of reflection.
- is the azimuthal angle of reflection.