Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Cython optimization #11

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Add Cython optimization #11

wants to merge 4 commits into from

Conversation

nuwandda
Copy link

Overview: This pull request introduces two functions that enhance image processing capabilities for the project. These functions enable efficient image transformation and mask creation, both of which are critical for image segmentation and manipulation tasks.

  1. set_value: This function processes a 2D NumPy array (grayscale image) and modifies its values based on specified conditions. Specifically, it updates pixel values that are neither 0 nor 255 to 127, enabling a simple transformation suitable for pre-processing before other image manipulation or analysis.
  2. pil_to_binary_mask: This function converts a PIL.Image to a binary mask based on a specified threshold value. It first converts the image to grayscale, then applies a threshold to determine which pixels should be part of the binary mask. This function is useful for tasks such as image segmentation, where binary masks are often used to isolate regions of interest in an image.

Changes Made:

  • set_value: Adds parallelized processing to efficiently modify the NumPy array in a multi-threaded context.
  • pil_to_binary_mask: Converts a PIL.Image to a binary mask by applying a threshold to grayscale pixel values.

Why This Pull Request Is Important:

  • It introduces efficient image processing capabilities that will be helpful in various use cases such as segmentation, masking, and image pre-processing.
  • The set_value function is optimized for performance with parallel processing, allowing for faster execution on large datasets.
  • The pil_to_binary_mask function provides a simple and effective way to create binary masks from images, which is a common operation in image analysis and computer vision.

How To Compile:
Just run python setup.py build_ext --inplace

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant