{"id":18382351,"url":"https://github.com/li-plus/seam-carving","last_synced_at":"2026-03-04T02:31:55.233Z","repository":{"id":45471459,"uuid":"310515611","full_name":"li-plus/seam-carving","owner":"li-plus","description":"A super-fast Python implementation of seam carving algorithm for intelligent image resizing.","archived":false,"fork":false,"pushed_at":"2022-11-17T06:17:22.000Z","size":2661,"stargazers_count":110,"open_issues_count":0,"forks_count":23,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-17T08:54:54.252Z","etag":null,"topics":["computer-graphics","computer-vision","image-processing","image-resizing","python","seam-carving"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/li-plus.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}},"created_at":"2020-11-06T06:50:32.000Z","updated_at":"2025-09-02T21:46:41.000Z","dependencies_parsed_at":"2023-01-23T07:45:48.776Z","dependency_job_id":null,"html_url":"https://github.com/li-plus/seam-carving","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/li-plus/seam-carving","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-plus%2Fseam-carving","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-plus%2Fseam-carving/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-plus%2Fseam-carving/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-plus%2Fseam-carving/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/li-plus","download_url":"https://codeload.github.com/li-plus/seam-carving/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/li-plus%2Fseam-carving/sbom","scorecard":{"id":587304,"data":{"date":"2025-08-11","repo":{"name":"github.com/li-plus/seam-carving","commit":"586dbe909ce69518e1602af30440a5f851a8b65f"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/python-package.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/6 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/li-plus/seam-carving/python-package.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/python-package.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/li-plus/seam-carving/python-package.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/python-package.yml:32: update your workflow using https://app.stepsecurity.io/secureworkflow/li-plus/seam-carving/python-package.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/python-package.yml:39: update your workflow using https://app.stepsecurity.io/secureworkflow/li-plus/seam-carving/python-package.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/python-package.yml:29","Warn: pipCommand not pinned by hash: .github/workflows/python-package.yml:30","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   2 third-party GitHubAction dependencies pinned","Info:   0 out of   2 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 3 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-20T20:53:33.988Z","repository_id":45471459,"created_at":"2025-08-20T20:53:33.988Z","updated_at":"2025-08-20T20:53:33.988Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30070080,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T01:03:42.280Z","status":"online","status_checked_at":"2026-03-04T02:00:07.464Z","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":["computer-graphics","computer-vision","image-processing","image-resizing","python","seam-carving"],"created_at":"2024-11-06T01:04:38.149Z","updated_at":"2026-03-04T02:31:55.204Z","avatar_url":"https://github.com/li-plus.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Seam Carving\n\n[![PyPI](https://img.shields.io/pypi/v/seam-carving)](https://pypi.org/project/seam-carving/)\n[![Unit Test](https://github.com/li-plus/seam-carving/workflows/Unit%20Test/badge.svg?branch=master)](https://github.com/li-plus/seam-carving/actions)\n[![License: MIT](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://github.com/li-plus/seam-carving/blob/master/LICENSE)\n[![codecov](https://codecov.io/gh/li-plus/seam-carving/branch/master/graph/badge.svg)](https://codecov.io/gh/li-plus/seam-carving)\n\nA super-fast Python implementation of [Seam carving for content-aware image resizing](https://dl.acm.org/doi/abs/10.1145/1275808.1276390), and the forward energy function proposed in [Improved seam carving for video retargeting](https://dl.acm.org/doi/abs/10.1145/1360612.1360615).\n\nWith seam carving algorithm, the image could be intelligently resized while keeping the important contents undistorted. The carving process could be further guided, so that an object could be removed from the image without apparent artifacts.\n\n## Installation\n\nInstall a stable version from PyPI.\n\n```shell script\npip install seam-carving\n```\n\nOr install the latest version from GitHub.\n\n```shell script\npip install git+https://github.com/li-plus/seam-carving.git@master\n```\n\n## Quick Start\n\nTo resize an image using seam carving:\n\n```python\nimport numpy as np\nfrom PIL import Image\nimport seam_carving\n\nsrc = np.array(Image.open(\"fig/castle.jpg\"))\nsrc_h, src_w, _ = src.shape\ndst = seam_carving.resize(\n    src,  # source image (rgb or gray)\n    size=(src_w - 200, src_h),  # target size\n    energy_mode=\"backward\",  # choose from {backward, forward}\n    order=\"width-first\",  # choose from {width-first, height-first}\n    keep_mask=None,  # object mask to protect from removal\n)\nImage.fromarray(dst).show()\n```\n\nTo remove an object from the image:\n\n```python\nsrc = np.array(Image.open(\"fig/beach.jpg\"))\nmask = np.array(Image.open(\"fig/beach_girl.png\").convert(\"L\"))\ndst = seam_carving.resize(src, drop_mask=mask)\nImage.fromarray(dst).show()\n```\n\nFor more examples, please refer to [example/demo.ipynb](example/demo.ipynb).\n\n## Example Results\n\n### Scaling Up \u0026 Down\n\nResizing along the x-axis using the original backward energy function:\n\n![](docs/basic.jpg)\n\n### Backward Energy vs Forward Energy\n\nReducing the width using backward \u0026 forward energy functions:\n\n![](fig/bench.jpg)\n\n![](docs/backward_vs_forward.jpg)\n\n### Aspect Ratio Change\n\nThe image width and height could be changed simultaneously in an optimal seam order, but the order has little effect on the final result. Currently we only support two kinds of seam orders: `width-first` and `height-first`. In `width-first` mode, we remove or insert all vertical seams first, and then the horizontal ones, while `height-first` is the opposite.\n\n![](docs/aspect_ratio.jpg)\n\n### Object Protection\n\nThe protected mask is not affected by seam removal and insertion.\n\n![](docs/object_protection.jpg)\n\n### Object Removal\n\nSpecify an object mask to remove (red) and a mask to protect (green, optional).\n\n![](docs/object_removal.jpg)\n\n## Benchmarks\n\nWe compare the performance of our implementation and other popular Python repos on [castle.jpg](fig/castle.jpg) (600x407). The image is narrowed or widened by 200 pixels using backward energy (BE) or forward energy (FE), respectively. Below is the running time (second) evaluated on a MacBook Pro.\n\n| Methods                                                                                 | BE -200px | BE +200px | FE -200px | FE +200px |\n| --------------------------------------------------------------------------------------- | --------- | --------- | --------- | --------- |\n| [vivianhylee/seam-carving](https://github.com/vivianhylee/seam-carving)                 | 168.47    | 179.52    | 89.24     | 90.27     |\n| [andrewdcampbell/seam-carving](https://github.com/andrewdcampbell/seam-carving)         | 119.47    | 126.44    | 133.29    | 133.73    |\n| [sameeptandon/python-seam-carving](https://github.com/sameeptandon/python-seam-carving) | 69.18     | 95.21     | N/A       | N/A       |\n| [dharness/seam_carving](https://github.com/dharness/seam_carving)                       | 50.25     | 57.86     | N/A       | N/A       |\n| [Ours](https://github.com/li-plus/seam-carving)                                         | **1.03**  | **1.08**  | **1.07**  | **1.17**  |\n\n## References\n\n* Avidan, S., \u0026 Shamir, A. (2007). Seam carving for content-aware image resizing. In ACM SIGGRAPH 2007 papers (pp. 10-es). [[paper]](https://dl.acm.org/doi/abs/10.1145/1275808.1276390) [[blog]](https://faculty.idc.ac.il/arik/SCWeb/imret/index.html)\n* Rubinstein, M., Shamir, A., \u0026 Avidan, S. (2008). Improved seam carving for video retargeting. ACM transactions on graphics (TOG), 27(3), 1-9. [[paper]](https://dl.acm.org/doi/abs/10.1145/1360612.1360615)\n* Das, A. (2019). Improved seam carving with forward energy. [[blog]](https://avikdas.com/2019/07/29/improved-seam-carving-with-forward-energy.html)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fli-plus%2Fseam-carving","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fli-plus%2Fseam-carving","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fli-plus%2Fseam-carving/lists"}