International Operations Management MGMT 6367 Lecture 08 Instructor: Yan Qin.
Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis...
-
Upload
derek-brammer -
Category
Documents
-
view
224 -
download
2
Transcript of Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis...
![Page 1: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/1.jpg)
Chamfer Distance for Handshape Detection and Recognition
CSE 6367 – Computer VisionVassilis Athitsos
University of Texas at Arlington
![Page 2: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/2.jpg)
Contours
• A contour is a curve/line (typically not straight) that delineates the boundary of a region, or between regions.
![Page 3: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/3.jpg)
Shapes Without Texture
• Letters/numbers.
• Contours.
• Edge templates.
![Page 4: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/4.jpg)
Detecting Shapes Without Texture
• Normalized correlation does not work well.
• Slight misalignments have a great impact on the correlation score.
star1 star3 combined
![Page 5: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/5.jpg)
Chamfer Distance
• For each edge pixel in star1:– How far is it from the nearest edge pixel in star3?
• The average of all those answers is the directed chamfer distance from star1 to star3.
![Page 6: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/6.jpg)
Chamfer Distance
• For each edge pixel in star1:– How far is it from the nearest edge pixel in star3?
• The average of all those answers is the directed chamfer distance from star1 to star3.
![Page 7: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/7.jpg)
Chamfer Distance
• For each edge pixel in star1:– How far is it from the nearest edge pixel in star3?
• The average of all those answers is the directed chamfer distance from star1 to star3.
![Page 8: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/8.jpg)
Chamfer Distance
• For each edge pixel in star1:– How far is it from the nearest edge pixel in star3?
• The average of all those answers is the directed chamfer distance from star1 to star3.
![Page 9: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/9.jpg)
Chamfer Distance
• For each edge pixel in star3:– How far is it from the nearest edge pixel in star1?
• The average of all those answers is the directed chamfer distance from star3 to star1.
![Page 10: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/10.jpg)
• Input: two sets of points.– red, green.
• c(red, green):– Average distance from each
red point to nearest green point.
Directed Chamfer Distance
![Page 11: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/11.jpg)
• Input: two sets of points.– red, green.
• c(red, green):– Average distance from each
red point to nearest green point.
• c(green, red):– Average distance from each
green point to nearest red point.
Directed Chamfer Distance
![Page 12: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/12.jpg)
• Input: two sets of points.– red, green.
• c(red, green):– Average distance from each red
point to nearest green point.
• c(green, red):– Average distance from each red
point to nearest green point.
Chamfer Distance
Chamfer distance:C(red, green) = c(red, green) + c(green, red)
![Page 13: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/13.jpg)
Chamfer Distance
• On two stars:– 31 pixels are nonzero in both images.
• On star and crescent: – 33 pixels are nonzero in both images.
• Correlation scores can be misleading.
![Page 14: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/14.jpg)
Chamfer Distance
• Chamfer distance is much smaller between the two stars than between the star and the crescent.
![Page 15: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/15.jpg)
Detecting Hands
Input imageTemplate.
• Problem: hands are highly deformable.
• Normalized correlation does not work as well.
• Alternative: use edges.
![Page 16: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/16.jpg)
Detecting Hands
• Compute chamfer distance, at all windows, all scales, with template.
• Which version? Directed or undirected?
• We want small distance with correct window, large distance with incorrect windows.
window template
![Page 17: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/17.jpg)
Direction Matters
• Chamfer distance from window to template: problems?
window template
![Page 18: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/18.jpg)
Direction Matters
• Chamfer distance from window to template: problems?
• Clutter (edges not belonging to the hand) cause the distance to be high.
window template
![Page 19: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/19.jpg)
Direction Matters
• Chamfer distance from template to window: problems?
window template
![Page 20: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/20.jpg)
Direction Matters
• Chamfer distance from template to window: problems?
• What happens when comparing to a window with lots of edges?
window template
![Page 21: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/21.jpg)
Direction Matters
• Chamfer distance from template to window: problems?
• What happens when comparing to a window with lots of edges? Score is low.
window template
![Page 22: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/22.jpg)
Choice of Direction
• For detection, we compute chamfer distance from template to window.• Being robust to clutter is a big plus, ensures the
correct results will be included.• Incorrect detections can be discarded with
additional checks.
window template
![Page 23: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/23.jpg)
Computing the Chamfer Distance
• Compute chamfer distance, at all windows, all scales, with template.
• Can be very time consuming.
![Page 24: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/24.jpg)
Distance Transform
Edge image e1 Distance transform d1
• For every pixel, compute distance to nearest edge pixel.
d1 = bwdist(e1);
![Page 25: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/25.jpg)
Distance Transform
Edge image e1 Distance transform d1
• If template t1 is of size (r, c):
• Chamfer distance with a window (i:(i+r-1), (j:(j+c-1)) of e1 can be written as:
t1
![Page 26: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/26.jpg)
Distance Transform
• If template t1 is of size (r, c):• Chamfer distance with a window
(i:(i+r-1), (j:(j+c-1)) of e1 can be written as:
• Computing image of chamfer scores for one scale:
window = d1(i:(i+r-1), j:(j+c-1));sum(sum(t1 .* window))
Edge image e1 Distance transform d1
t1
![Page 27: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/27.jpg)
Distance Transform
• Computing image of chamfer scores for one scale s
• How long does that take? Can it be more efficient?
resized = imresize(image, s, 'bilinear');resized_edges = canny(resized, 7);resized_dt = bwdist(resized_edges);chamfer_scores = imfilter(resized_dt, t1, 'symmetric');figure(3); imshow(chamfer_scores, []);
Edge image e1 Distance transform d1
t1
![Page 28: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/28.jpg)
Improving Efficiency
• Which parts of the template contribute to the score of each window?
Edge image e1 Distance transform d1
t1
![Page 29: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/29.jpg)
Improving Efficiency
• Which parts of the template contribute to the score of each window?
• Just the nonzero parts.• How can we use that?
Edge image e1 Distance transform d1
t1
![Page 30: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/30.jpg)
Improving Efficiency
• Which parts of the template contribute to the score of each window? Just the nonzero parts.
• How can we use that?• Compute a list of non-zero pixels in the template.• Consider only those pixels when computing the sum for
each window.
Edge image e1 Distance transform d1
t1
![Page 31: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/31.jpg)
Results for Single Scale Search
• What is causing the false result?
![Page 32: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/32.jpg)
Results for Single Scale Search
• What is causing the false result?– Window with lots of edges.
• How can we refine these results?
![Page 33: Chamfer Distance for Handshape Detection and Recognition CSE 6367 – Computer Vision Vassilis Athitsos University of Texas at Arlington.](https://reader035.fdocuments.net/reader035/viewer/2022062515/56649c775503460f9492c424/html5/thumbnails/33.jpg)
Results for Single Scale Search
• What is causing the false result?– Window with lots of edges.
• How can we refine these results?– Skin color, or background subtraction