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

[prototype] ImageDtype trait to implement resize for various dtypes #68

Merged
merged 6 commits into from
Apr 2, 2024
Merged

[prototype] ImageDtype trait to implement resize for various dtypes #68

merged 6 commits into from
Apr 2, 2024

Conversation

gau-nernst
Copy link
Contributor

@gau-nernst gau-nernst commented Mar 29, 2024

This is my prototype to support resize with different dtypes. Justifications for trait

  • Copy trait: to get the value out of ndarray::Array<T, _>
  • Default trait: to get 0 value
  • Into<f32> trait: to convert to f32 for internal computation i.e. bilinear/bicubic
  • Send and Sync trait: required for ndarray::Zip::par_for_each()
  • from_f32() function: convert from internal computation dtype f32 back to original dtype. We can't use From<f32> since it is undefined-behavior with underflow and overflow values i.e. we need to clamp the value by ourselves.

I think ImageDtype trait can be moved to image.rs and data within Image must implement ImageDtype trait i.e. these are the dtype that we support -> pub struct Image<T: ImageDtype, const CHANNELS: usize>

Copy link
Member

@edgarriba edgarriba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let’s somehow verify we don’t break anything , maybe add different types test

@edgarriba edgarriba merged commit 8d38e1b into kornia:main Apr 2, 2024
8 of 9 checks passed
@gau-nernst gau-nernst deleted the resize_u8 branch April 2, 2024 22:54
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.

2 participants