{"id":31755635,"url":"https://github.com/justin-marian/dithering","last_synced_at":"2025-10-09T18:56:44.178Z","repository":{"id":314652280,"uuid":"1051146493","full_name":"justin-marian/dithering","owner":"justin-marian","description":"End-to-end dithering toolkit: (naïve threshold; ordered; random; error; adaptive; plus multi-level palette) diffusion methods.","archived":false,"fork":false,"pushed_at":"2025-09-13T20:27:55.000Z","size":1395,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-13T21:39:54.783Z","etag":null,"topics":["dithering","dithering-images","dithering-methods","package-python","python3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/justin-marian.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-05T14:10:36.000Z","updated_at":"2025-09-13T20:27:58.000Z","dependencies_parsed_at":"2025-09-13T21:50:15.569Z","dependency_job_id":null,"html_url":"https://github.com/justin-marian/dithering","commit_stats":null,"previous_names":["justin-marian/dithering"],"tags_count":null,"template":true,"template_full_name":null,"purl":"pkg:github/justin-marian/dithering","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justin-marian%2Fdithering","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justin-marian%2Fdithering/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justin-marian%2Fdithering/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justin-marian%2Fdithering/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/justin-marian","download_url":"https://codeload.github.com/justin-marian/dithering/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/justin-marian%2Fdithering/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279001866,"owners_count":26083226,"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","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["dithering","dithering-images","dithering-methods","package-python","python3"],"created_at":"2025-10-09T18:56:43.340Z","updated_at":"2025-10-09T18:56:44.170Z","avatar_url":"https://github.com/justin-marian.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dithering\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"images/dithering.jpg\" alt=\"Dithering\" width=\"1080\" height=\"320\"\u003e\n\u003c/p\u003e\n\nCollection of classic and modern dithering algorithms that convert grayscale/color images to black \u0026 white using various error distribution techniques.\n\n**Algorithms:** \n\n- naïve threshold\n- ordered (Bayer \u0026 halftone)\n- random\n- error diffusion (Floyd-Steinberg, JJN, Stucki, Sierra, Burkes, Atkinson…)\n- adaptive diffusion (Ostromoukhov, Zhou–Fang) \n- multi-level \n- palette diffusion\n\nUses random image from `./assets/` or falls back to `skimage.data.astronaut()`. \n\nResults preview and/or save to `./output/`.\n\n## Install\n\n```bash\npython3 -m pip install -e .  # Python 3.10+\n```\n\n## Usage\n\n```bash\n# Show options and available kernels\ndither --help\n\n# Error diffusion comparison\ndither --task error_diffusion --kernels FS,JJN,stucki --save\n\n# Ordered dithering\ndither --task ordered --bayer-n 8 --save\n\n# Adaptive methods  \ndither --task adaptive_diffusion --save\n\n# Simple thresholding\ndither --task naive --threshold 128 --save\n\n# Multi-level grayscale\ndither --task multi_level --levels 6 --save\n```\n\n## Implemented Methods\n\n- **Naïve:** Global, mean, percentile, and Otsu thresholding\n- **Ordered:** Bayer matrices (2×2 to 16×16), halftone spot functions\n- **Random:** Per-pixel random threshold\n- **Error Diffusion:** Floyd–Steinberg, Jarvis–Judice–Ninke, Stucki, Sierra family, Burkes, Atkinson, Stevenson–Arce\n- **Adaptive Diffusion:** Ostromoukhov (content-aware weights), Zhou–Fang (threshold jitter)\n- **Multi-level:** Custom palette diffusion with configurable gray levels\n\n## Key Options\n\n- `--task {naive, ordered, random, error_diffusion, adaptive_diffusion, multi_level}`: Selects the dithering algorithm.\n- `--kernels \u003clist\u003e`: Specifies error diffusion kernels (e.g., FS, JJN, stucki).\n- `--threshold \u003c0-255\u003e`: Sets the threshold value for naïve methods.\n- `--bayer-n {2, 4, 8, 16}`: Chooses Bayer matrix size for ordered dithering.\n- `--levels \u003cint\u003e`: Number of gray levels for multi-level dithering.\n- `--save`: Saves output images to `./outputs/`.\n- `--no-serpentine`: Disables alternating scan direction in error diffusion.\n\n## Library API\n\n```python\nfrom naive.threshold import threshold_bw\nfrom error_diffusion.err_diff import error_diff_bw\nfrom ordered.ordered import ordered_bw\n\n# Apply different algorithms\nresult = threshold_bw(img, method=\"otsu\")\nresult = error_diff_bw(img, kernel_type=\"floyd_steinberg\") \nresult = ordered_bw(img, kind=\"bayer\", n=8)\n```\n\nAll functions return grayscale uint8 images (0/255), except multi-level which returns RGB.\n\n### Data Files\n\n```\nsrc/adaptive_diffusion/kernels/data/\n├── weights_ostromoukhov.txt    # 256 × 3 matrix [wR, wDL, wD]\n└── strengths_zhou_fang.txt     # Grid lookup for jitter strength\n```\n\n### Generated Outputs\n\n| Method | Algorithm | File |\n|--------|-----------|------|\n| **Adaptive Diffusion** | Ostromoukhov | `lenna_adaptive_diffusion_ostromoukhov.png` |\n| **Adaptive Diffusion** | Zhou-Fang | `lenna_adaptive_diffusion_zhou_fang.png` |\n| **Error Diffusion** | Atkinson | `lenna_error_diffusion_atkinson.png` |\n| **Error Diffusion** | Burkes | `lenna_error_diffusion_burkes.png` |\n| **Error Diffusion** | Floyd-Steinberg | `lenna_error_diffusion_floyd_steinberg.png` |\n| **Error Diffusion** | Jarvis-Judice-Ninke | `lenna_error_diffusion_jarvis_judice_ninke.png` |\n| **Error Diffusion** | Sierra | `lenna_error_diffusion_sierra.png` |\n| **Error Diffusion** | Stevenson-Arce | `lenna_error_diffusion_stevenson_arce.png` |\n| **Error Diffusion** | Stucki | `lenna_error_diffusion_stucki.png` |\n| **Error Diffusion** | Two-row Sierra | `lenna_error_diffusion_two_row_sierra.png` |\n| **Multi-level** | 4 levels | `lenna_multi_level_multi_level_4.png` |\n| **Naïve** | Global | `lenna_naive_naive_global.png` |\n| **Naïve** | Mean | `lenna_naive_naive_mean.png` |\n| **Naïve** | Otsu | `lenna_naive_naive_otsu.png` |\n| **Naïve** | Percentile | `lenna_naive_naive_percentile.png` |\n| **Ordered** | Bayer 8×8 | `lenna_ordered_bayer_8.png` |\n| **Ordered** | Halftone 8px 45deg | `lenna_ordered_halftone_8px_45deg.png` |\n| **Random** | Random threshold | `lenna_random_random_threshold.png` |\n\n**Naming pattern:** `{image}_{method}_{algorithm}[_parameters].png`\n\n### License UNLICENSE (public domain)\n\n```\nDocumentation:\nThis README file provides information about the dithering project, \nincluding usage instructions, features, and relevant details for contributors and users.\n\nLicense:\nThis project is released under a short license description. \nPlease refer to the LICENSE file for full terms and conditions.\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustin-marian%2Fdithering","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjustin-marian%2Fdithering","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjustin-marian%2Fdithering/lists"}