{"id":32175549,"url":"https://github.com/pingjunchen/pycontour","last_synced_at":"2025-10-21T19:41:29.273Z","repository":{"id":46934672,"uuid":"143360185","full_name":"PingjunChen/pycontour","owner":"PingjunChen","description":"Contour python toolkit","archived":false,"fork":false,"pushed_at":"2024-08-30T23:51:37.000Z","size":2511,"stargazers_count":7,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-09-17T04:28:21.895Z","etag":null,"topics":["bbox","contour","detection","roi","segmentation"],"latest_commit_sha":null,"homepage":"https://pycontour.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PingjunChen.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":"2018-08-03T01:03:37.000Z","updated_at":"2024-09-05T12:11:23.000Z","dependencies_parsed_at":"2022-09-05T17:01:42.127Z","dependency_job_id":null,"html_url":"https://github.com/PingjunChen/pycontour","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/PingjunChen/pycontour","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingjunChen%2Fpycontour","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingjunChen%2Fpycontour/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingjunChen%2Fpycontour/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingjunChen%2Fpycontour/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PingjunChen","download_url":"https://codeload.github.com/PingjunChen/pycontour/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PingjunChen%2Fpycontour/sbom","scorecard":{"id":110220,"data":{"date":"2025-08-11","repo":{"name":"github.com/PingjunChen/pycontour","commit":"13f64b685740368605db314b0f547f9f8dd4e737"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":2.1,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/18 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":-1,"reason":"no workflows found","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":"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":"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":-1,"reason":"No tokens found","details":null,"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":"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":-1,"reason":"no dependencies found","details":null,"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":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: BSD 3-Clause \"New\" or \"Revised\" 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":"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":"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":"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 'main'"],"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":"Vulnerabilities","score":3,"reason":"7 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2021-856 / GHSA-5545-2q6w-2gh6","Warn: Project is vulnerable to: GHSA-6p56-wp2h-9hxr","Warn: Project is vulnerable to: PYSEC-2019-108 / GHSA-9fq2-x9r6-wfmf","Warn: Project is vulnerable to: PYSEC-2021-857 / GHSA-f7c7-j99h-c22f","Warn: Project is vulnerable to: GHSA-fpfv-jqm9-f5jm","Warn: Project is vulnerable to: GHSA-qr4w-53vh-m672","Warn: Project is vulnerable to: PYSEC-2023-183"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 15 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-15T12:02:44.156Z","repository_id":46934672,"created_at":"2025-08-15T12:02:44.156Z","updated_at":"2025-08-15T12:02:44.156Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280325250,"owners_count":26311415,"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-21T02:00:06.614Z","response_time":58,"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":["bbox","contour","detection","roi","segmentation"],"created_at":"2025-10-21T19:41:27.853Z","updated_at":"2025-10-21T19:41:29.260Z","avatar_url":"https://github.com/PingjunChen.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"pycontour: A Python Toolkit for 2D Contour Processing\n============\n[![Codacy Badge](https://app.codacy.com/project/badge/Grade/ab444eaadd6c4309970562667e50b904)](https://www.codacy.com/gh/PingjunChen/pycontour/dashboard?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=PingjunChen/pycontour\u0026amp;utm_campaign=Badge_Grade)\n[![CircleCI](https://circleci.com/gh/PingjunChen/pycontour.svg?style=svg)](https://circleci.com/gh/PingjunChen/pycontour)\n[![Documentation Status](https://readthedocs.org/projects/pycontour/badge/?version=latest)](https://pycontour.readthedocs.io/en/latest/?badge=latest)\n[![PyPI version](https://badge.fury.io/py/pycontour.svg)](https://badge.fury.io/py/pycontour)\n[![codecov](https://codecov.io/gh/PingjunChen/pycontour/branch/master/graph/badge.svg)](https://codecov.io/gh/PingjunChen/pycontour)\n[![Downloads](https://pepy.tech/badge/pycontour)](https://pepy.tech/project/pycontour)\n![](https://img.shields.io/github/stars/PingjunChen/pycontour.svg)\n\n\u003cimg src=\"./docs/media/contour_representation.png\" width=\"800\" height=\"270\" alt=\"Contour Representation\"\u003e\n\n\nMotivation\n------------\nContour is one of the most important concept in plenty of image-based applications, mainly for the representation of region of interest (ROI), especially in medical imaging applications. [OpenCV](http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_tutorials.html) and [shapely](http://shapely.readthedocs.io/en/stable/manual.html) both provide some contour functionalities. However, the contour representation looks obscure and strange for developers.\n\nThis package tries to standardize the contour representation in python. Different from OpenCV, the contour here is represented as a numpy 2d array with shape 2*N (0-h 1-w), in which height always comes first, shown as the figure above. We believe this representation is the most intuitive way for developers to understand and use. Moreover, back and forth conversion between this representation with OpenCV or shapely are supported, enabling developers to take advantage of the functionalities of both OpenCV and shapely. We also add contour utilities, such as feature extraction, statistic metric calculation, shifting and rotation, mask construction, etc. to simplify contour usage. If you find [pycontour](https://github.com/PingjunChen/pycontour) to be helpful for your work, please `star` this repo.\n\n\nInstallation\n------------\nTo install pycontour, libgeos need to install in advance. Other required packages can refer to requirements.txt.\n```bash\n# install dependencies\nsudo apt-get install libgeos-dev\n# install relied packages\npip install -r requirements.txt\n# install pycontour\npip install pycontour==1.5.1\n```\n\n\nFunctionalities \u0026 Usage Examples\n------------\n\u003cpre\u003e\u003ccode\u003e\n# Representation Transformation\n- back-and-forth transformation with cv2 representation\n- back-and-forth transformation with shapely Polygon\n```python\nimport numpy as np\n# with OpenCV Representation\nfrom pycontour.cv2_transform import cv_cnt_to_np_arr, np_arr_to_cv_cnt\nnp_arr1 = np.array([[1, 0, 2, 3, 5, 4], [0, 2, 4, 3, 1, 0]])\ncv_cnt = np_arr_to_cv_cnt(np_arr1)\nnp_arr2 = cv_cnt_to_np_arr(cv_cnt)\nassert np.array_equal(np_arr1, np_arr2), \"Back and forth transformation not equal\"\n# with Shapely Polygon\nfrom pycontour.poly_transform import np_arr_to_poly, poly_to_np_arr\nnp_arr1 = np.array([[1, 0, 2, 3, 5, 4], [0, 2, 4, 3, 1, 0]])\npoly = np_arr_to_poly(np_arr1)\nnp_arr2 = poly_to_np_arr(poly)\nassert np.array_equal(np_arr1, np_arr2), \"Back and forth transformation not equal\"\n# with Point List\nfrom pycontour.coor_transform import point_list_to_np_arr, np_arr_to_point_list\nnp_arr1 = np.array([[1, 0, 2, 3, 5, 4], [0, 2, 4, 3, 1, 0]])\npoint_list = np_arr_to_point_list(np_arr1)\nnp_arr2 = point_list_to_np_arr(point_list)\nassert np.array_equal(np_arr1, np_arr2), \"Back and forth transformation not equal\"\n```\n\n# Contour Features\n- area, aspect ratio, solidity, bounds, etc.\n\n# Interconversion of Contour and Image\n- constructing binary image based on contour\n- masking image based on contour    \n```python\nimport numpy as np\nfrom pycontour.img import build_cnt_mask\nnp_arr1 = np.array([[1, 0, 2, 3, 5, 4], [0, 2, 4, 3, 1, 0]])\nmask = build_cnt_mask(np_arr1)\n```\n\n# Feature Extraction\n- ZernikeMoments feature extraction\n```python\nimport numpy as np\nfrom pycontour.fea import ZernikeMoments\nnp_arr1 = np.array([[1, 0, 2, 3, 5, 4], [0, 2, 4, 3, 1, 0]])\nzernike_desc = ZernikeMoments(radius=21)\ncnt_fea = zernike_desc.cal_fea(np_arr1)\nassert len(cnt_fea) == 25, \"Feature error\"\n```\n\n# Contour Relationship\n- point with contour\n- contour with contour\n- overlapping ratio (Dice coefficient, Jaccard index, etc.)\n\n# Shape Transformation\n- rotate, shift, smooth, etc.\n\u003c/code\u003e\u003c/pre\u003e\n\n\nDocumentation\n------------\nHosted in [https://pycontour.readthedocs.io](https://pycontour.readthedocs.io), powered by [readthedocs](https://readthedocs.org) and\n[Sphinx](http://www.sphinx-doc.org).\n\n\nContributing\n------------\n``pycontour`` is an open source project and anyone is welcome to contribute. An easy way to get started is by suggesting a new enhancement on the [Issues](https://github.com/PingjunChen/pycontour/issues). If you have found a bug, then either report this through [Issues](https://github.com/PingjunChen/pycontour/issues), or even better, fork the repository, fix the bug and then create a [Pull Request](https://github.com/PingjunChen/pycontour/pulls).\n\n\nContributors\n------------\nSee the [AUTHORS.md](AUTHORS.md) file for a complete list of contributors to the project.\n\n\nLicense\n------------\n``pycontour`` is free software made available under the BSD 3-Clause License. For details see the [LICENSE](LICENSE) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingjunchen%2Fpycontour","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpingjunchen%2Fpycontour","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpingjunchen%2Fpycontour/lists"}