Update to visioncortex 0.4.0

This commit is contained in:
Chris Tsang
2020-12-19 01:34:01 +08:00
parent bb3b66780b
commit 433a68d6d6
8 changed files with 39 additions and 24 deletions

View File

@@ -46,7 +46,7 @@ impl Canvas {
image.data().to_vec()
}
pub fn get_image_data_as_image(&self, x: u32, y: u32, width: u32, height: u32) -> ColorImage {
pub fn get_image_data_as_color_image(&self, x: u32, y: u32, width: u32, height: u32) -> ColorImage {
ColorImage {
pixels: self.get_image_data(x, y, width, height),
width: width as usize,

View File

@@ -54,7 +54,7 @@ impl BinaryImageConverter {
pub fn init(&mut self) {
let width = self.canvas.width() as u32;
let height = self.canvas.height() as u32;
let image = self.canvas.get_image_data_as_image(0, 0, width, height);
let image = self.canvas.get_image_data_as_color_image(0, 0, width, height);
let binary_image = image.to_binary_image(|x| x.r < 128);
self.clusters = binary_image.to_clusters(false);
self.canvas.log(&format!(

View File

@@ -1,6 +1,6 @@
use wasm_bindgen::prelude::*;
use visioncortex::PathSimplifyMode;
use visioncortex::color_clusters::{IncrementalBuilder, Clusters, Runner, RunnerConfig};
use visioncortex::color_clusters::{IncrementalBuilder, Clusters, Runner, RunnerConfig, HIERARCHICAL_MAX};
use crate::canvas::*;
use crate::svg::*;
@@ -64,8 +64,10 @@ impl ColorImageConverter {
pub fn init(&mut self) {
let width = self.canvas.width() as u32;
let height = self.canvas.height() as u32;
let image = self.canvas.get_image_data_as_image(0, 0, width, height);
let image = self.canvas.get_image_data_as_color_image(0, 0, width, height);
let runner = Runner::new(RunnerConfig {
diagonal: self.params.layer_difference == 0,
hierarchical: HIERARCHICAL_MAX,
batch_size: 25600,
good_min_area: self.params.filter_speckle,
good_max_area: (width * height) as usize,