mirror of
https://github.com/visioncortex/vtracer.git
synced 2025-12-06 17:15:41 -08:00
Refactor
This commit is contained in:
@@ -73,7 +73,7 @@ fn should_key_image(img: &ColorImage) -> bool {
|
|||||||
|
|
||||||
// Check for transparency at several scanlines
|
// Check for transparency at several scanlines
|
||||||
let threshold = ((img.width * 2) as f32 * KEYING_THRESHOLD) as usize;
|
let threshold = ((img.width * 2) as f32 * KEYING_THRESHOLD) as usize;
|
||||||
let mut num_transparent_boundary_pixels = 0;
|
let mut num_transparent_pixels = 0;
|
||||||
let y_positions = [
|
let y_positions = [
|
||||||
0,
|
0,
|
||||||
img.height / 4,
|
img.height / 4,
|
||||||
@@ -84,9 +84,9 @@ fn should_key_image(img: &ColorImage) -> bool {
|
|||||||
for y in y_positions {
|
for y in y_positions {
|
||||||
for x in 0..img.width {
|
for x in 0..img.width {
|
||||||
if img.get_pixel(x, y).a == 0 {
|
if img.get_pixel(x, y).a == 0 {
|
||||||
num_transparent_boundary_pixels += 1;
|
num_transparent_pixels += 1;
|
||||||
}
|
}
|
||||||
if num_transparent_boundary_pixels >= threshold {
|
if num_transparent_pixels >= threshold {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,14 +233,14 @@ impl ColorImageConverter {
|
|||||||
|
|
||||||
// Check for transparency at several scanlines
|
// Check for transparency at several scanlines
|
||||||
let threshold = ((img.width * 2) as f32 * KEYING_THRESHOLD) as usize;
|
let threshold = ((img.width * 2) as f32 * KEYING_THRESHOLD) as usize;
|
||||||
let mut num_transparent_boundary_pixels = 0;
|
let mut num_transparent_pixels = 0;
|
||||||
let y_positions = [0, img.height / 4, img.height / 2, 3 * img.height / 4, img.height - 1];
|
let y_positions = [0, img.height / 4, img.height / 2, 3 * img.height / 4, img.height - 1];
|
||||||
for y in y_positions {
|
for y in y_positions {
|
||||||
for x in 0..img.width {
|
for x in 0..img.width {
|
||||||
if img.get_pixel(x, y).a == 0 {
|
if img.get_pixel(x, y).a == 0 {
|
||||||
num_transparent_boundary_pixels += 1;
|
num_transparent_pixels += 1;
|
||||||
}
|
}
|
||||||
if num_transparent_boundary_pixels >= threshold {
|
if num_transparent_pixels >= threshold {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user