Title: More Image Processing Operations
1More Image Processing Operations
- Some operations we want to cover
- Edge detection, enhancement, etc.
- Region growing
2Edge Detection
- We want to find the boundary between two regions
abrupt change - Were looking for derivatives
- A derivative is a type of high-pass filter
- Whats a derivative in 2D?
3Gradients
- An image gradient consists of the horizontal and
vertical partial derivatives
4Derivative Estimators
- Most trivial Simple difference
- Note All must add to zero
- Problems
- Derivatives enhance noise
- We desire some filtering
- We prefer odd sized filters, not even
- Note relation to high-pass filtering
Horz
Vert
5Better Derivative Estimators
- Prewitt operator
- Sobel operator
Horz
Vert
Horz
Vert
TT
6Steps (so far)
- Compute two Gx and Gy
- Using some derivative estimation filter
7Determining edge locations
- We are interested in the magnitude of the
gradient at each pixel - For each pixel
- Determine magnitude based on gradient images
- Test against a threshold
8Example code
// Filter that returns absolute values
Filter3x3A(inImg, hfilt, sobelH)
Filter3x3A(inImg, vfilt, sobelV) //
Determine where the edges are for(int r0
rltouImg.Height() r) for(int
c0 cltouImg.Width() 3 c)
double p1 hfiltrc double
p2 vfiltrc if(sqrt(p1 p1
p2 p2) gt m_threshold)
ouImg.Set(c/3, r, 255, 0, 0)
9Improving Efficiency
- Square root per pixel is very expensive
- We can approximate using absolute values
if(abs(hfiltrc) abs(vfiltrc) gt
m_threshold)
ouImg.Set(c/3, r, 255, 0, 0)
TT
10Region Growing
- Given a point in the image
- Use color at point as region color
- Flag point as in region
- Push point onto stack
- While(stack not empty)
- t lt- Pop stack
- For each neighbor of t
- if similar color and not visited before
- Flag point as in region
- push point onto stack
TT
11Keeping track of the visited
- Dummy image
- Specific values in output image
- Destroying input image
12Comparing Colors
- Vector distance
- Manhattan distance
- Maximum in any dimension
13Alternative color systems and myths
- RGB is a poor perceptual system
- HLS is better for human color selection
- H Hue the color
- S Saturation How pure the color is
- L Luminance the Brightness
- HLS can be a poor choice for region growing (or
other color comparisons) - If S 0, H does not matter
- If L 0 or 100, H and S do not matter
14The RGB color cube
Blu
What do our distance measures mean here?
Grn
Red
15RGB Color cube looking down the gray line
Blu
Magenta
Cyan
Grn
Red
Yellow
16The Hexacone HLS model
- Parameters
- H Angle relative to red
- L Height from black
- S Percentage of way from center
TT
17Combining region growing and edge detection
- Assume an image of only detected edges
- What if I click on a non-edge pixel?
- What if I click on an edge pixel?
18Edge linking
- Following edges to decide which are contiguous
and the paths - How can we describe a path?