Skip to main content

This repository provides a tool to calculate the area of polygons in semantic segmentation data, specifically for images in YOLO format. It enables the precise calculation of areas for objects defined as polygons within images. This tool is useful for researchers and developers in analyzing and evaluating segmentation tasks.

Project description

PolygonAreaSegmentation

Overview

The meaPolygon function calculates the area of polygons based on coordinates provided in a text file and corresponding image dimensions. This function is useful for tasks where polygonal regions of an image need to be analyzed, such as in image segmentation or object detection.

Additionally, this function is designed to work with text files formatted for semantic segmentation in the YOLO format. This means that it can accurately process polygon coordinates that are normalized relative to image dimensions, as commonly used in YOLO-based object detection and segmentation tasks.

PyPI version

Original Yolo format Semantic Segmentation

Original                                                                         Yolo format Semantic Segmentation

Installation

First, install the necessary dependencies. After cloning or downloading this project, run the following command to install the package:

pip3 install .
pip install meaPolygon

This will install the module containing the meaPolygon function, making it available for use in your Python environment.

Usage

  1. Prepare the YOLO Format Text File Prepare a text file formatted for YOLO semantic segmentation. Each line should contain a label and normalized polygon coordinates.

Example:

0 0.1 0.2 0.3 0.4 0.5 0.6
1 0.2 0.3 0.4 0.5 0.6 0.7
  1. Create a Python Script
from my_module.polygon_area import meaPolygon

# Specify the paths to the image file and the text file
img_path = "examples/data/example.png"
txt_path = "examples/data/example.txt"

# Calculate the polygon areas
areas = meaPolygon(img_path, txt_path)

# Display the results
print("Calculated Polygon Areas:", areas)
  1. Run the Script
python3 your_script.py

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

meapolygon-0.0.3.tar.gz (4.5 kB view details)

Uploaded Source

File details

Details for the file meapolygon-0.0.3.tar.gz.

File metadata

  • Download URL: meapolygon-0.0.3.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.11.9

File hashes

Hashes for meapolygon-0.0.3.tar.gz
Algorithm Hash digest
SHA256 dab7a0a2deab4587154574e9dc335132048f88144011eb4a8f5f890220b786aa
MD5 748618b05ed4e6b4735cd3ec4cfc6776
BLAKE2b-256 d51f9f2b24edc5bdd0dbfca4ff0123091d3ff6fb6e3e8893a887da2db0808968

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page