FeatureCrop is a Python library designed to automatically crop an image
Project description
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
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
- Preprocessing: The input image is converted to grayscale and a Laplacian filter is applied to detect edges.
- Contour Detection: Contours are detected using OpenCV's contour detection functions.
- Contour Analysis: Closed contours are identified and analyzed based on their hierarchy and area.
- 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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file featurecrop-0.0.1.tar.gz
.
File metadata
- Download URL: featurecrop-0.0.1.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29078405aa50da516b777c52bf2acec2830618c10b7d75e48bd42f8722bcdbdb |
|
MD5 | 706749138e9f5499aa08ba0d14b8ab95 |
|
BLAKE2b-256 | 1cff644ee3c0f2b627c709394994a25c939fe522e0c80acb432966ce3051a6a2 |
File details
Details for the file featurecrop-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: featurecrop-0.0.1-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.0.0 CPython/3.12.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f30a8e9ffcb6d927c1c6e80a2cc36c9bfb66c209ef9b5ad352743e567a560a7 |
|
MD5 | 45e3cff820e8d6ceec6c428113d81b2b |
|
BLAKE2b-256 | 2c392f3e88d76e82591febed5febc94fdc94a8770e4f99cf366b97043ee759a2 |