Skip to main content

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

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.


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

featurecrop-0.0.1.tar.gz (7.4 kB view hashes)

Uploaded Source

Built Distribution

featurecrop-0.0.1-py3-none-any.whl (7.6 kB view hashes)

Uploaded Python 3

Supported by

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