# twotwothree **Converts 2D images into 3D-looking, stylized shaded images (anime / cel-shaded presets).** --- ## Overview `twotwothree` is a small Rust command-line tool that analyzes an input image to compute a depth map, normals, edges, and ambient occlusion, then applies stylized shading to produce a 3D-looking output image. It ships with an **anime** preset for quick stylized results and also exposes parameters to tune depth and shading. Built with: **Rust**, `image`, `nalgebra`, `clap`, `anyhow`. --- ## Quickstart Build (release recommended): ```bash cargo build --release ``` Run CLI (example): ```bash cargo run --release -- input.png output.png ``` After a successful run you'll see: > Saved: ./out/output.png ### Web Server & UI Run the HTTP server: ```bash cargo run --bin server --release ``` Then open **http://localhost:3000/demos/223/** in your browser: - **Upload**: Convert images with adjustable anime preset, depth scale, and gamma - **Gallery**: Browse publicly shared conversions - **Contact**: Find contact info and GitHub link - **Dark Mode**: Toggle light/dark theme (persisted in localStorage) --- ## Usage Basic CLI: ```text Usage: twotwothree [OPTIONS] Args: Input image file (png, jpeg, ...) Output image file (png recommended) Options: --anime Anime preset (default: true) --depth-scale Depth scale modifier (used when --anime=false, default: 1.0) --depth-gamma Depth gamma (used when --anime=false, default: 1.0) -h, --help Print help information -V, --version Print version ``` Notes: - The `--anime` preset chooses conservative depth/gamma values for a stylized look. To customize depth values, disable the preset with `--no-anime` or `--anime false` and pass `--depth-scale` / `--depth-gamma`. Example (disable anime and increase depth): ```bash cargo run --release -- input.png output.png --no-anime --depth-scale 1.5 --depth-gamma 1.2 ``` --- ## Examples & Tips - Use high-resolution inputs for better detail in the computed depth map. - The tool writes a PNG (and other formats supported by the `image` crate) to the specified output path. - The algorithm applies shading, rim lighting, ambient occlusion, edge enhancement, and optional cel shading — tweak parameters in code if you want custom effects. --- ## Internals - `compute_depth_map` converts pixel brightness (and alpha) into a depth buffer, with optional "bulge" toward the image center to suggest camera projection. - `compute_normals`, `compute_edge_strength`, and `compute_ambient_occlusion` prepare shading data. - `apply_shading` composes ambient, diffuse, specular, rim effects, saturation and bloom to produce the final color. --- ## Roadmap - Improve performance (parallelize more work / optimize memory). - Add unit/integration tests and example-based visual tests. - Add API documentation for `/api/convert` and `/api/upload` endpoints. --- ## License This project is licensed under the MIT License — see the `LICENSE` file. ---