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

[Suggestion] Support multiple pixels to search with the AND option #65

Open
aoz001 opened this issue Feb 5, 2025 · 4 comments
Open
Labels
enhancement New feature or request

Comments

@aoz001
Copy link

aoz001 commented Feb 5, 2025

Currently, it seems that the library only supports the OR search for multiple pixels. It would be very useful if it could also support the AND option

@iseahound
Copy link
Owner

iseahound commented Feb 5, 2025

I assume you cropped your area and want to test if 2 pixels of different colors match? The library is minimalistic so you can stack 2x pixelsearch. Each instance of pixelsearch runs at 4000+ fps on my laptop!! I added the OR function in assembly code to give about a 1.5x speedup. There likely isn't a good speedup with the AND operation because the logic would be complex, making the SIMD vectorization hard. But rest assured, since the base speed is so fast, you can write your won custom function that wraps my pixelsearch without worries.

Also, it is hard to beat pic.pixelsearch(red) and pic.pixelsearch(green) for clarity. I can't think of a better syntax.

@iseahound iseahound added the enhancement New feature or request label Feb 6, 2025
@iseahound
Copy link
Owner

@aoz001 if you think of a good syntax, i'll add it in.

@aoz001
Copy link
Author

aoz001 commented Feb 7, 2025

Perhaps the operator argument can be added to the option object.

pic := ImagePutBuffer({ window:  "ahk_id " hWnd, 'operator': 'AND'})
xy := pic.PixelSearch([0xFFFFFF, 0x000000], 3)

@iseahound
Copy link
Owner

There will be multithreading improvements to ImagePut. This should give the "and" operator for free. This may take a while.

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

No branches or pull requests

2 participants