{"id":24904930,"url":"https://github.com/okaneco/skeletonize","last_synced_at":"2025-08-09T21:13:46.283Z","repository":{"id":57667563,"uuid":"344480954","full_name":"okaneco/skeletonize","owner":"okaneco","description":"Line thinning library for binary images","archived":false,"fork":false,"pushed_at":"2023-01-14T22:20:44.000Z","size":98,"stargazers_count":18,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-01T08:07:59.330Z","etag":null,"topics":["computer-vision","edge-detection","edge-thinning","image-processing","line-thinning","morphology","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/okaneco.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-03-04T13:18:46.000Z","updated_at":"2024-12-03T08:52:05.000Z","dependencies_parsed_at":"2023-02-09T20:45:34.340Z","dependency_job_id":null,"html_url":"https://github.com/okaneco/skeletonize","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okaneco%2Fskeletonize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okaneco%2Fskeletonize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okaneco%2Fskeletonize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/okaneco%2Fskeletonize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/okaneco","download_url":"https://codeload.github.com/okaneco/skeletonize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":236735028,"owners_count":19196362,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["computer-vision","edge-detection","edge-thinning","image-processing","line-thinning","morphology","rust"],"created_at":"2025-02-01T23:46:04.524Z","updated_at":"2025-02-01T23:46:05.178Z","avatar_url":"https://github.com/okaneco.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# skeletonize\n\n[![Build Status](https://github.com/okaneco/skeletonize/workflows/Rust%20CI/badge.svg)](https://github.com/okaneco/skeletonize/)\n[![Crates.io](https://img.shields.io/crates/v/skeletonize.svg)](https://crates.io/crates/skeletonize)\n[![Docs.rs](https://docs.rs/skeletonize/badge.svg)](https://docs.rs/skeletonize)\n\n![\"skeletonize\" original text and line thinned text](gfx/skeletonize-title.png)\n\nA line thinning library for binary images, including edge detection and\nthreshold functions for preprocessing images into binary images.\n\nThe goal of line thinning is to remove excess pixels from the image until the\nlines present are one pixel wide, resembling a \"skeleton\" of the original\npattern. Thinning is useful for removing noise from images which have had\nimage processing filters applied to them such as edge detection. Line thinning\nis similar to erosion, another morphological operator.\n\nThe thinning algorithms are based on the papers *Zhang \u0026 Suen, 1984* and\n*Chen \u0026 Hsu, 1988*. See [Reference](#reference).\n\nThis crate requires the input to be a type from the `image` crate. To use this\ncrate, add the following to your `Cargo.toml`.\n\n```toml\n[dependencies.skeletonize]\nversion = \"0.2\"\n```\n\n#### Features\n\n- 2 line thinning algorithms\n- support for black or white foreground color\n- Sobel operator edge detection\n- thresholding for binarization (turning an image into only black and\nwhite pixels)\n\nThe example [`skeletonize.rs`](examples/skeletonize.rs) is a command line\nprogram available for download as a binary executable from the repository\n[`Releases`][releases] page.\n\n## Thinning Algorithms Comparison\n\n*Images should be viewed at 100% magnification to avoid scaling artifacts.*\n\n![Original image and line thinning processed images](gfx/chenhsu-append.png)\n![Comparison of Standard and Modified algorithms](gfx/chenhsu-standard-modified.gif)  \n*First image, left to right: Figures 7(b) and 7(c) from Chen \u0026 Hsu, 1988,\n`Standard` algorithm result, `Modified` algorithm result.*  \n*Second image: Animated comparison of the `Standard` and `Modified` marking\nmethods.*\n\nThe *Chen \u0026 Hsu* `Modified` algorithm tends to produce better line connectivity,\nless noise, and more consistent single pixel width lines than the *Zhang \u0026 Suen*\n`Standard` algorithm.\n\nThe original image can be found in the `gfx` folder entitled `chenhsu.png`. It\nwas thresholded at `0.3` to convert it into a binary image before line thinning.\nThe example program produced the image results with the following arguments. The\n`--method|-m` option allows for selecting the standard or modified pixel marking\nalgorithm, `--threshold|-t` is the gray level threshold.\n\n```bash\n-i chenhsu.png -t 0.3 -m s -o chenhsu-standard.png\n-i chenhsu.png -t 0.3 -m m -o chenhsu-modified.png\n```\n\n## [`skeletonize.rs`](examples/skeletonize.rs)\n\nThe `skeletonize` example program exposes library functions as a command line\napplication. It can be run with the following command or by invoking it directly\nafter downloading from [`Releases`][releases]/building it yourself.\n\n```bash\ncargo r --release --example skeletonize -- [args]\n```\n### Examples\n\nThe next three examples use this image as the input. All examples include the\nequivalent library code.\n\n![Original image](gfx/rustacean.png)\n\n---\n\nPerform edge detection with `sobel4` (4-way edge detection) and line thinning,\nthreshold the edge detection filter to `0.3`.\n\n```bash\ncargo r --release --example skeletonize -- -i rustacean.png -e sobel4 -t 0.3\n```\n\n```rust\nlet mut filtered = sobel4::\u003cforeground::Black\u003e(\u0026img, Some(0.3))?;\nthin_image_edges::\u003cforeground::Black\u003e(\u0026mut filtered, method, None)?;\n```\n\n![Edge detected crab](gfx/edgedetect-t03.png)\n\n---\n\nPerform edge detection with no line thinning, threshold the edge detection\nfilter to `0.3`, and set the `--foreground|-f` color to white.\n\n```bash\n-i rustacean.png -e sobel4 -t 0.3 --no-thin -f white\n```\n\n```rust\nlet filtered = sobel4::\u003cforeground::White\u003e(\u0026img, Some(0.3))?;\n```\n\n![Edge detected crab with no thinning](gfx/edgedetect-no-thin.png)\n\n---\n\nReturn the grayscale edge detection image by omitting the `--threshold|-t` and\nusing `--no-thin`. Aliases are used for `sobel4` and `white`.\n\n```bash\n-i rustacean.png -e s4 --no-thin -f w\n```\n\n```rust\nlet filtered = sobel4::\u003cforeground::White\u003e(\u0026img, None))?;\n```\n\n![Edge detected crab with no thinning](gfx/edgedetect-no-thin-no-threshold.png)\n\n---\n\nThe title image was created with the following arguments.\n\n```bash\n-i skeletonize.png -t 0.3\n```\n\n```rust\nskeletonize::threshold(\u0026mut img, 0.3)?;\nthin_image_edges::\u003cforeground::Black\u003e(\u0026mut img, method, None)?;\n```\n\n\u003ca name=\"reference\"\u003e\u003c/a\u003e\n## Reference\n\n*Zhang, T. Y. \u0026 Suen, C. Y. (1984). A fast parallel algorithm for thinning\ndigital patterns. Commun. ACM 27, 3 (March 1984), 236–239.\n[DOI:10.1145/357994.358023](https://doi.org/10.1145/357994.358023)*\n\n*Chen, Yung-Sheng \u0026 Hsu, Wen-Hsing. (1988). A modified fast parallel algorithm\nfor thinning digital patterns. Pattern Recognition Letters. 7. 99-106.\n[DOI:10.1016/0167-8655(88)90124-9](https://doi.org/10.1016/0167-8655(88)90124-9)*\n\n## License\n\nThis crate is licensed under either\n- the [MIT License](LICENSE-MIT), or\n- the [Apache License (Version 2.0)](LICENSE-APACHE)\n\nat your option.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n\n\n[releases]: https://github.com/okaneco/skeletonize/releases\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokaneco%2Fskeletonize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fokaneco%2Fskeletonize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fokaneco%2Fskeletonize/lists"}