image-area-calculator


Nameimage-area-calculator JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/clabe-wekesa/image-area-calculator
SummaryA package to calculate real-world areas of contours in images using a image of known length for scaling.
upload_time2024-08-17 16:12:50
maintainerNone
docs_urlNone
authorClabe Wekesa
requires_python>=3.6
licenseMIT
keywords image processing contours area calculation opencv
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Image Area Calculator

This Python application is a versatile tool designed for calculating the real-world areas of contours in an image by referencing a known object for scaling. Built with OpenCV for powerful image processing, this tool can handle both standard image files and PDFs (with automatic conversion to images if needed). Users can accurately measure areas in square centimeters by selecting points on an object of known length within the image.

The application is fully command-line driven, making it ideal for automation, scripting, and integration into larger workflows. With just a few command-line options, users can specify input files, set image processing parameters, rotate images, and output the results to CSV files for further analysis. Whether you're working with scanned documents, photos, or any other images containing measurable objects, this tool offers a straightforward and efficient solution for area measurement.

### Purpose of the Package

The Image Area Calculator offers a straightforward solution for anyone needing to measure areas in images accurately. Whether you're working with scanned documents, photos, or any other images containing measurable objects, this tool allows you to calculate areas in real-world units (cm²) by referencing a known object in the image. The package supports image files directly and can also convert PDF files to images for processing.

### Features

- Automatically converts single-page PDF files to JPEG images for processing.
- Allows users to select two points on a reference object in the image to calculate the scale, then calculates and displays areas of contours in the image in square centimeters (cm²).
- Supports rotating images by a specified angle to correct the orientation before processing.
- Exports the calculated areas and contour coordinates to a CSV file for further analysis.
- Displays the image with calculated areas overlaid directly on the contours, making it easy to visualize the results.

### Installation Instructions

**1. Python Environment**  
Requires [Python 3](https://www.python.org/) environment. Ensure you have it installed on your computer.

```shell
pip install image-area-calculator
```
**2. Additional Dependencies**  
The application uses the following libraries, which will be automatically installed via pip:
- Click (for handling command-line options and arguments)
- OpenCV (for image processing)
- pdf2image (for PDF to image conversion)
- NumPy (for numerical calculations)

### Usage
After installation, you can use the tool directly from the command line. For example:

```shell
calculate-areas --image 'path/to/image.jpg' \
                 --ref_length 5 \
                 --threshold_value 127 \
                 --maxval 255 \
                 --area_threshold 200 \
                 --rotation_angle 90 \
                 --output 'output_areas.csv'
```

Command-Line Options
- `-i, --image`: Path to the input image or PDF file. This is required.
- `-l, --ref_length`: The length of the reference object in centimeters. This is required to calculate the scale.
- `-t, --threshold_value`: The threshold value for binarization (default is 127). Adjust if needed for better contour detection.
- `-m, --maxval`: The maximum value for binary thresholding (default is 255).
- `-a, --area_threshold`: Minimum contour area in pixels to consider (default is 200). Adjust to filter out smaller contours.
- `-R, --rotation_angle`: Angle to rotate the image in degrees (default is 0). Use this if the image needs to be rotated.
- `-o, --output`: Path to save the CSV file with contour areas (default is derived from the image name).  

### Acknowledgment
The development of this application draws upon various Python libraries, particularly OpenCV for image processing and pdf2image for handling PDF files. These tools are critical for enabling the image manipulation and analysis capabilities of this package.

### Author
[Dr. Clabe Wekesa](https://www.ice.mpg.de/246268/group-members) 

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/clabe-wekesa/image-area-calculator",
    "name": "image-area-calculator",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": "image processing, contours, area calculation, opencv",
    "author": "Clabe Wekesa",
    "author_email": "simiyu86wekesa@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6f/54/fa7cd470f7fb6a9b2825706ca00c48a36d1e0231f29a00e77d9bd1a128d2/image_area_calculator-0.1.0.tar.gz",
    "platform": null,
    "description": "# Image Area Calculator\n\nThis Python application is a versatile tool designed for calculating the real-world areas of contours in an image by referencing a known object for scaling. Built with OpenCV for powerful image processing, this tool can handle both standard image files and PDFs (with automatic conversion to images if needed). Users can accurately measure areas in square centimeters by selecting points on an object of known length within the image.\n\nThe application is fully command-line driven, making it ideal for automation, scripting, and integration into larger workflows. With just a few command-line options, users can specify input files, set image processing parameters, rotate images, and output the results to CSV files for further analysis. Whether you're working with scanned documents, photos, or any other images containing measurable objects, this tool offers a straightforward and efficient solution for area measurement.\n\n### Purpose of the Package\n\nThe Image Area Calculator offers a straightforward solution for anyone needing to measure areas in images accurately. Whether you're working with scanned documents, photos, or any other images containing measurable objects, this tool allows you to calculate areas in real-world units (cm\u00b2) by referencing a known object in the image. The package supports image files directly and can also convert PDF files to images for processing.\n\n### Features\n\n- Automatically converts single-page PDF files to JPEG images for processing.\n- Allows users to select two points on a reference object in the image to calculate the scale, then calculates and displays areas of contours in the image in square centimeters (cm\u00b2).\n- Supports rotating images by a specified angle to correct the orientation before processing.\n- Exports the calculated areas and contour coordinates to a CSV file for further analysis.\n- Displays the image with calculated areas overlaid directly on the contours, making it easy to visualize the results.\n\n### Installation Instructions\n\n**1. Python Environment**  \nRequires [Python 3](https://www.python.org/) environment. Ensure you have it installed on your computer.\n\n```shell\npip install image-area-calculator\n```\n**2. Additional Dependencies**  \nThe application uses the following libraries, which will be automatically installed via pip:\n- Click (for handling command-line options and arguments)\n- OpenCV (for image processing)\n- pdf2image (for PDF to image conversion)\n- NumPy (for numerical calculations)\n\n### Usage\nAfter installation, you can use the tool directly from the command line. For example:\n\n```shell\ncalculate-areas --image 'path/to/image.jpg' \\\n                 --ref_length 5 \\\n                 --threshold_value 127 \\\n                 --maxval 255 \\\n                 --area_threshold 200 \\\n                 --rotation_angle 90 \\\n                 --output 'output_areas.csv'\n```\n\nCommand-Line Options\n- `-i, --image`: Path to the input image or PDF file. This is required.\n- `-l, --ref_length`: The length of the reference object in centimeters. This is required to calculate the scale.\n- `-t, --threshold_value`: The threshold value for binarization (default is 127). Adjust if needed for better contour detection.\n- `-m, --maxval`: The maximum value for binary thresholding (default is 255).\n- `-a, --area_threshold`: Minimum contour area in pixels to consider (default is 200). Adjust to filter out smaller contours.\n- `-R, --rotation_angle`: Angle to rotate the image in degrees (default is 0). Use this if the image needs to be rotated.\n- `-o, --output`: Path to save the CSV file with contour areas (default is derived from the image name).  \n\n### Acknowledgment\nThe development of this application draws upon various Python libraries, particularly OpenCV for image processing and pdf2image for handling PDF files. These tools are critical for enabling the image manipulation and analysis capabilities of this package.\n\n### Author\n[Dr. Clabe Wekesa](https://www.ice.mpg.de/246268/group-members) \n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A package to calculate real-world areas of contours in images using a image of known length for scaling.",
    "version": "0.1.0",
    "project_urls": {
        "Homepage": "https://github.com/clabe-wekesa/image-area-calculator"
    },
    "split_keywords": [
        "image processing",
        " contours",
        " area calculation",
        " opencv"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "dcf28fffa834afd280fae264aa7c9093f6817b9af41a2e7124cbbb2d0352ea48",
                "md5": "ba36cf7b7174d438bd961bd7e63760ff",
                "sha256": "b6d105e59422c9c196784513d8b8bafcb73d042f9f79f4d95a5354a38588c7cc"
            },
            "downloads": -1,
            "filename": "image_area_calculator-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ba36cf7b7174d438bd961bd7e63760ff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 6549,
            "upload_time": "2024-08-17T16:12:48",
            "upload_time_iso_8601": "2024-08-17T16:12:48.952443Z",
            "url": "https://files.pythonhosted.org/packages/dc/f2/8fffa834afd280fae264aa7c9093f6817b9af41a2e7124cbbb2d0352ea48/image_area_calculator-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6f54fa7cd470f7fb6a9b2825706ca00c48a36d1e0231f29a00e77d9bd1a128d2",
                "md5": "0092a30ebf25abbfaace2052178eda59",
                "sha256": "c59557da499966ad6207c6b457d88f19d1d4a20eefbec4671275f4bf154db261"
            },
            "downloads": -1,
            "filename": "image_area_calculator-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "0092a30ebf25abbfaace2052178eda59",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 5987,
            "upload_time": "2024-08-17T16:12:50",
            "upload_time_iso_8601": "2024-08-17T16:12:50.434685Z",
            "url": "https://files.pythonhosted.org/packages/6f/54/fa7cd470f7fb6a9b2825706ca00c48a36d1e0231f29a00e77d9bd1a128d2/image_area_calculator-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-08-17 16:12:50",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "clabe-wekesa",
    "github_project": "image-area-calculator",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "image-area-calculator"
}
        
Elapsed time: 1.20777s