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

Optimize QRColorMask apply_mask method for enhanced performance #372

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smalyu
Copy link

@smalyu smalyu commented Sep 2, 2024

This commit introduces optimizations to the apply_mask method in the QRColorMask class to improve performance. Changes include:

  1. Replacing getpixel and putpixel with direct pixel manipulation using the load() method, which speeds up the process.
  2. Implementing a caching mechanism to reuse color transformations for identical pixel colors, reducing redundant calculations.
  3. Adding conditions to skip processing for background color pixels to reduce computational load.

These optimizations have significantly reduced the method's execution time. In some experiments, these changes have resulted in performance improvements of over ten times compared to the original method, especially for larger images.

This commit introduces optimizations to the apply_mask method in the QRColorMask class to improve performance. Changes include:

1. Replacing getpixel and putpixel with direct pixel manipulation using the load() method, which speeds up the process.
2. Implementing a caching mechanism to reuse color transformations for identical pixel colors, reducing redundant calculations.
3. Adding conditions to skip processing for background color pixels to reduce computational load.

These optimizations have significantly reduced the method's execution time. In some experiments, these changes have resulted in performance improvements of over ten times compared to the original method, especially for larger images.
@smalyu
Copy link
Author

smalyu commented Sep 15, 2024

Hi! Just wanted to follow up on this PR. I believe these changes can significantly improve performance, especially for larger images. Let me know if there's anything that needs to be adjusted or clarified!

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