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 write_area_to_binary and get_pixel #157

Merged
merged 3 commits into from
Jul 26, 2024
Merged

Add write_area_to_binary and get_pixel #157

merged 3 commits into from
Jul 26, 2024

Conversation

akash-akya
Copy link
Owner

@akash-akya akash-akya commented Jul 20, 2024

Added new generic function write_area_to_binary which extracts a region to raw binary in a single NIF call as an optimization.

write_to_binary, write_to_tensor, to_list and others now use this function so there might be slight performance gain.

get_pixel internally just calls write_area_to_binary with width & height 1 and returns a 1D list of band values.

# the value will be based on the image band_format and colorspace
{:ok, [r, g, b]} = Image.get_pixel(image, 10, 10)

@akash-akya
Copy link
Owner Author

@kipcole9 can you take look? I'll add docs, tests and refactor a bit later.

@akash-akya akash-akya merged commit ccb6f75 into master Jul 26, 2024
22 of 24 checks passed
@akash-akya akash-akya deleted the dev branch July 26, 2024 10:59
@akash-akya
Copy link
Owner Author

Addresses #153

@kipcole9
Copy link
Contributor

Awesome work as always Akash, I'll give this a spin over the next couple of days. Thanks very much.

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.

None yet

2 participants