Modify contour finding to return path vertices instead of trace
This commit is contained in:
1 parent
d550a7e71e
commit
a7372d05c2
2 files changed
+72
-53
No files matched your search
@@ -21,12 +21,15 @@ fn main() -> std::process::ExitCode {
|
||||
let thresholded = filter::threshold_auto(greyscale);
|
||||
let contours = contour::find(thresholded);
|
||||
for contour in contours {
|
||||
for (x, y) in contour.trace {
|
||||
*img.at_mut(x, y) = match contour.kind {
|
||||
contour::Kind::Inner => INNER,
|
||||
contour::Kind::Outer => OUTER,
|
||||
};
|
||||
}
|
||||
let n = contour.vertices.len();
|
||||
for i in 0..n {
|
||||
let (x0, y0) = contour.vertices[i];
|
||||
let (x1, y1) = contour.vertices[(i + 1) % n];
|
||||
draw::line(x0, y0, x1, y1, &mut img, match contour.kind {
|
||||
contour::Kind::Outer => OUTER,
|
||||
contour::Kind::Inner => INNER,
|
||||
});
|
||||
}
|
||||
}
|
||||
img
|
||||
})
|
||||
|
||||
Reference in new issue
Block a user