Skip to main content

Collection of image processing tools and techniques, including padding, flipping, colorscale conversion, seam carving, and image shrinking. Designed for efficient manipulation and transformation of images.

Project description

SharpEdge

Documentation Status Python 3.11 codecov ci-cd

Collection of image processing tools and techniques, including padding, flipping, colorscale conversion, seam carving, and image shrinking. Designed for efficient manipulation and transformation of images.

Summary

This package provides a comprehensive set of image processing utilities tailored for seamless integration of image manipulation projects. It includes essential tools for image transformations, seam carving, and processing. This package enables users to efficiently prepare, manipulate and modify image based on the needs of the user. The sharpedge package is valuable for users seeking tools for resizing and compressing images while maintaining visual content integrity.

Functions

  • reposition_image
    This function allows you to manipulate the position and orientation of an image by flipping, rotating, or shifting it. You can customize the actions based on your needs, such as horizontal flips, rotation to the left or right, or shifting the image along the X and Y axes.

  • frame_image
    Enhance the aesthetic of your image by adding a decorative frame around it. The frame can be customized with adjustable border sizes, placement inside or outside the image, and a specified color for the border.

  • modulate_image
    Modify the color channels of an image to achieve effects like grayscale conversion or specific channel isolation. This function is useful for color manipulation tasks, including transforming RGB images to simpler formats for analysis or artistic purposes.

  • pooling_image
    Apply pooling techniques to an image using a defined window size and a specified function, such as mean or max pooling. Pooling is commonly used to reduce image dimensions while preserving key features, making it especially relevant for preprocessing in computer vision tasks.

  • pca_compression
    Compress an image using Principal Component Analysis (PCA) by retaining only the most significant features while discarding less important data. This method is ideal for reducing file size while preserving a specified proportion of the original variance in the image.

  • seam_carve
    Resize an image intelligently using seam carving to preserve important content while adjusting dimensions. This technique minimizes distortion by removing or inserting paths of least importance, making it effective for content-aware resizing.

Where This Fits in the Python Ecosystem

This package fits into the broader Python image ecosystem, along with packages like OpenCV, Pillow, and scikit-learn. While OpenCV and Pillow provide general-purpose image processing tools, and scikit-learn includes PCA for dimensionality reduction, this package stands out for its simplicity and streamlined functionality. It specializes in content-aware resizing and transformations, focusing on practical utilities for advanced image manipulations. It offers unique capabilities, allowing users to accomplish tasks quickly without needing to manage complex parameters.

Installation

$ pip install sharpedge

Usage

For detailed explanations, tutorials, and image examples for each function, visit our official documentation.

To harness the image processing magic of SharpEdge, follow these steps:

  1. Import the required functions from the package:

    from sharpedge import reposition_image
    from sharpedge import frame_image
    from sharpedge import modulate_image
    from sharpedge import pooling_image
    from sharpedge import pca_compression
    from sharpedge import seam_carve
    
  2. (Optional) Load your image as a NumPy array.

    # Ensure that you have matplotlib and numpy installed in your environment
    import matplotlib.pyplot as plt
    import numpy as np
    
    # Load the image from the given path
    img = plt.imread(PATH_TO_IMAGE)
    
    # Only execute this conversion for functions other than seam_carve
    # Convert the loaded image to the range [0, 255] and cast it to np.uint8 
    # This is necessary for processing images with most functions, but 'seam_carve' handles float inputs directly
    img = np.round(np.clip(img * 255, 0, 255)).astype(np.uint8)
    
  3. Process your images using the available functions:

    • Flip, rotate, and shift an image based on the specified requested action:

      # Flip horizontally, rotate left, and shift the image
      repositioned_img = reposition_image(img, flip='horizontal', rotate='left', shift_x=10, shift_y=20)
      
    • Add a decorative frame around the image with customizable color:

      # Add a frame around your image
      framed_img = frame_image(img, h_border=30, w_border=30, inside=True, color=255)
      
    • Convert or manipulate image color channels:

      # Convert an RGB image to grayscale
      grayscale_image = modulate_image(rgb_image, mode='gray')
      
    • Perform pooling on an image using a specified window size and pooling function:

      # Perform pooling on an image with mean pooling function
      pooled_img = pooling_image(img, window_size=10, func=np.mean)
      
    • Compress the input image using Principal Component Analysis (PCA):

      # Compress a grayscale image by retaining 80% of the variance
      compressed_img = pca_compression(grayscale_img, preservation_rate=0.8)
      
    • Resize the image using seam carving to the target dimensions:

      # Seam carve an image to resize it to the target dimensions
      resized_img = seam_carve(img, target_height=300, target_width=400)
      

Contributors

Archer Liu, Hankun Xiao, Inder Khera, Jenny Zhang (ordered alphabetically)

Contributing

Interested in contributing? Check out the contributing guidelines. Please note that this project is released with a Code of Conduct. By contributing to this project, you agree to abide by its terms.

License

sharpedge was created by Jenny Zhang, Archer Liu, Inder Khera, Hankun Xiao. It is licensed under the terms of the MIT license.

Credits

sharpedge was created with cookiecutter and the py-pkgs-cookiecutter template.

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

sharpedge-1.1.10.tar.gz (16.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sharpedge-1.1.10-py3-none-any.whl (18.2 kB view details)

Uploaded Python 3

File details

Details for the file sharpedge-1.1.10.tar.gz.

File metadata

  • Download URL: sharpedge-1.1.10.tar.gz
  • Upload date:
  • Size: 16.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for sharpedge-1.1.10.tar.gz
Algorithm Hash digest
SHA256 9d03ab21cda76fdbecfb406c0494c6b55c7198374f3a36fe435bc507a61ab193
MD5 f8b547b7dde52ef97c2a76f77faaf464
BLAKE2b-256 6d52b251e4cdf0a6d473394d0408377417924e110ecd4e6204c22f7529a73d0b

See more details on using hashes here.

File details

Details for the file sharpedge-1.1.10-py3-none-any.whl.

File metadata

  • Download URL: sharpedge-1.1.10-py3-none-any.whl
  • Upload date:
  • Size: 18.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for sharpedge-1.1.10-py3-none-any.whl
Algorithm Hash digest
SHA256 da4125ffb7b605d836d4aa1f7d95123933065e0e31c8da1313325544a9dc316f
MD5 105965a85ac602a71e44ffcffcdfe1cc
BLAKE2b-256 85919d5ee52c44b6b9219c41d5b5cdb1ec1a2b1f1f9722f6dc06425b8a827211

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