Skip to main content

FeatureCrop

FeatureCrop is a Python library designed to automatically crop an image to the innermost closed contour containing the most feature data. It is particularly useful for applications where the focus is on extracting important features from an image while removing unnecessary background.

Installation

You can install FeatureCrop via pip:

pip install featurecrop

Usage

image

Basic Usage

from featurecrop import featurecrop
import cv2

# Load your image
image = cv2.imread('your_image.jpg')

# Perform autocropping
cropped_image = featurecrop.autocrop(image)

# Use the cropped image for further processing or display
cv2.imshow('Cropped Image', cropped_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

Options

You can also visualize the contours detected during the cropping process by setting the show_contours parameter to True:

cropped_image = featurecrop.autocrop(image, show_contours=True)

How it Works

  1. Preprocessing: The input image is converted to grayscale and a Laplacian filter is applied to detect edges.
  2. Contour Detection: Contours are detected using OpenCV's contour detection functions.
  3. Contour Analysis: Closed contours are identified and analyzed based on their hierarchy and area.
  4. Cropping: The innermost closed contour containing the most feature data is identified and used to crop the image.

Contributing

Contributions are welcome! If you encounter any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request on GitHub.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.


Metadata

Release files for featurecrop 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for featurecrop 0.0.1
File Size Uploaded
featurecrop-0.0.1.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for featurecrop 0.0.1
File Interpreter ABI Platform
featurecrop-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 14.9 kB

Release files / featurecrop-0.0.1.tar.gz

Download URL featurecrop-0.0.1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
29078405aa50da516b777c52bf2acec2830618c10b7d75e48bd42f8722bcdbdb
BLAKE2b-256 checksum
How to use checksums
1cff644ee3c0f2b627c709394994a25c939fe522e0c80acb432966ce3051a6a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / featurecrop-0.0.1-py3-none-any.whl

Download URL featurecrop-0.0.1-py3-none-any.whl
Size 7.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1f30a8e9ffcb6d927c1c6e80a2cc36c9bfb66c209ef9b5ad352743e567a560a7
BLAKE2b-256 checksum
How to use checksums
2c392f3e88d76e82591febed5febc94fdc94a8770e4f99cf366b97043ee759a2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page