6 Commits

Author SHA1 Message Date
Chris Tsang
8acb6bd911 bump fastrand
Some checks failed
Rust / build (push) Has been cancelled
2025-10-17 22:02:50 +01:00
Chris Tsang
efa4351b2c Update README.md 2024-09-27 10:43:47 +01:00
Chris Tsang
a46292b5ed Update README.md 2024-09-27 10:43:02 +01:00
Chris Tsang
8889cbc7ea Tweaks
Some checks failed
Rust / build (push) Has been cancelled
2024-09-26 12:59:45 +01:00
Wil Carmon
6b379a02ef Update svg.rs (#92) 2024-09-26 12:58:43 +01:00
Wil Carmon
2635d5b874 Update config.rs (#91)
added #[derive(Clone, Debug)]
2024-09-26 12:58:30 +01:00
5 changed files with 17 additions and 7 deletions

View File

@@ -122,11 +122,13 @@ VTracer is used by the following products (open a PR to add yours):
## Citations ## Citations
VTracer has since been cited in a few academic papers. Please kindly let us know if you have cited our work: VTracer has since been cited by a few academic papers in computer graphics / vision research. Please kindly let us know if you have cited our work:
+ [Framework to Vectorize Digital Artworks for Physical Fabrication based on Geometric Stylization Techniques](https://www.researchgate.net/publication/374448489_Framework_to_Vectorize_Digital_Artworks_for_Physical_Fabrication_based_on_Geometric_Stylization_Techniques) + SKILL 2023 [Framework to Vectorize Digital Artworks for Physical Fabrication based on Geometric Stylization Techniques](https://www.researchgate.net/publication/374448489_Framework_to_Vectorize_Digital_Artworks_for_Physical_Fabrication_based_on_Geometric_Stylization_Techniques)
+ [Image Vectorization: a Review](https://arxiv.org/pdf/2306.06441.pdf) + arXiv 2023 [Image Vectorization: a Review](https://arxiv.org/abs/2306.06441)
+ [StarVector: Generating Scalable Vector Graphics Code from Images](https://arxiv.org/abs/2312.11556) + arXiv 2023 [StarVector: Generating Scalable Vector Graphics Code from Images](https://arxiv.org/abs/2312.11556)
+ arXiv 2024 [Text-Based Reasoning About Vector Graphics](https://arxiv.org/abs/2404.06479)
+ arXiv 2024 [Delving into LLMs' visual understanding ability using SVG to bridge image and text](https://openreview.net/pdf?id=pwlm6Po61I)
## How did VTracer come about? ## How did VTracer come about?

View File

@@ -1,6 +1,6 @@
[package] [package]
name = "vtracer" name = "vtracer"
version = "0.6.4" version = "0.6.5"
authors = ["Chris Tsang <chris.2y3@outlook.com>"] authors = ["Chris Tsang <chris.2y3@outlook.com>"]
edition = "2021" edition = "2021"
description = "A cmd app to convert images into vector graphics." description = "A cmd app to convert images into vector graphics."
@@ -14,11 +14,12 @@ keywords = ["svg", "computer-graphics"]
clap = "2.33.3" clap = "2.33.3"
image = "0.23.10" image = "0.23.10"
visioncortex = { version = "0.8.8" } visioncortex = { version = "0.8.8" }
fastrand = "1.8" fastrand = { version = "2.3" }
pyo3 = { version = "0.19.0", optional = true } pyo3 = { version = "0.19.0", optional = true }
[features] [features]
python-binding = ["pyo3"] python-binding = ["pyo3"]
wasm = ["fastrand/js"]
[lib] [lib]
name = "vtracer" name = "vtracer"

View File

@@ -1,23 +1,27 @@
use std::str::FromStr; use std::str::FromStr;
use visioncortex::PathSimplifyMode; use visioncortex::PathSimplifyMode;
#[derive(Debug, Clone)]
pub enum Preset { pub enum Preset {
Bw, Bw,
Poster, Poster,
Photo, Photo,
} }
#[derive(Debug, Clone)]
pub enum ColorMode { pub enum ColorMode {
Color, Color,
Binary, Binary,
} }
#[derive(Debug, Clone)]
pub enum Hierarchical { pub enum Hierarchical {
Stacked, Stacked,
Cutout, Cutout,
} }
/// Converter config /// Converter config
#[derive(Debug, Clone)]
pub struct Config { pub struct Config {
pub color_mode: ColorMode, pub color_mode: ColorMode,
pub hierarchical: Hierarchical, pub hierarchical: Hierarchical,
@@ -32,6 +36,7 @@ pub struct Config {
pub path_precision: Option<u32>, pub path_precision: Option<u32>,
} }
#[derive(Debug, Clone)]
pub(crate) struct ConverterConfig { pub(crate) struct ConverterConfig {
pub color_mode: ColorMode, pub color_mode: ColorMode,
pub hierarchical: Hierarchical, pub hierarchical: Hierarchical,

View File

@@ -53,7 +53,7 @@ fn find_unused_color_in_image(img: &ColorImage) -> Result<Color, String> {
Color::new(0, 255, 255), Color::new(0, 255, 255),
Color::new(255, 0, 255), Color::new(255, 0, 255),
]); ]);
let rng = Rng::new(); let mut rng = Rng::new();
let random_colors = let random_colors =
(0..NUM_UNUSED_COLOR_ITERATIONS).map(|_| Color::new(rng.u8(..), rng.u8(..), rng.u8(..))); (0..NUM_UNUSED_COLOR_ITERATIONS).map(|_| Color::new(rng.u8(..), rng.u8(..), rng.u8(..)));
for color in special_colors.chain(random_colors) { for color in special_colors.chain(random_colors) {

View File

@@ -1,6 +1,7 @@
use std::fmt; use std::fmt;
use visioncortex::{Color, CompoundPath, PointF64}; use visioncortex::{Color, CompoundPath, PointF64};
#[derive(Debug, Clone)]
pub struct SvgFile { pub struct SvgFile {
pub paths: Vec<SvgPath>, pub paths: Vec<SvgPath>,
pub width: usize, pub width: usize,
@@ -8,6 +9,7 @@ pub struct SvgFile {
pub path_precision: Option<u32>, pub path_precision: Option<u32>,
} }
#[derive(Debug, Clone)]
pub struct SvgPath { pub struct SvgPath {
pub path: CompoundPath, pub path: CompoundPath,
pub color: Color, pub color: Color,