-
Notifications
You must be signed in to change notification settings - Fork 629
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 Rgb(a)32F DynamicImage Variant #1516
Conversation
…uplicate dynamic image byte functions | use real deprecation attribute instead of only documentation
…amic-image � Conflicts: � src/dynimage.rs
…lculate with f32 samples)
Here's a first draft. Would you like to discuss? These are the most important limitations of this approach concerning
These are the most important limitations of this approach concerning
Also, I could not resist doing some deprecation progress and code deduplication (boyscout rule). Furthermore,
|
So, can you do another review? Something blocking this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something blocking this?
Yeah, finding time for careful deliberation on the maintainability of the interface which I finally did. I'm pretty content with most of these changes. There's maybe two things that I find slightly annoying from an user perspective:
- Is the
Primitive
trait useful any more? We do control both of these traits after all. Due to the changes toPixel
everyone needs to switch toSample
anyways. The churn could be far less if we'd merge those two traits and just changePrimitive
.
Glad that you took the time :)
Yes, why not. However, I think |
Considering all the discussions about renaming and splitting, what do you think of the following /// The type of each channel in a pixel. For example, this can be `u8`, `u16`, `f32`.
// TODO rename to `PixelComponent`
pub trait Primitive: Copy + NumCast + Num + PartialOrd<Self> + Clone + Bounded {
const DEFAULT_MAX_COMPONENT_VALUE: Self = usize::MAX;
}
/* ... */
/// The type of each channel in a pixel, with an associated color type.
pub trait PixelComponentWithColorType: Primitive + 'static + private::Sealed {
const RGB_COLOR_TYPE: ColorTypeOrErr;
const RGBA_COLOR_TYPE: ColorTypeOrErr;
const L_COLOR_TYPE: ColorTypeOrErr;
const LA_COLOR_TYPE: ColorTypeOrErr;
} We can rename |
The main problem seems to be the associated |
So more concretely I would suppose something like this: /// The type of each channel in a pixel. For example, this can be `u8`, `u16`, `f32`.
// TODO rename to `PixelComponent`
pub trait Primitive: Copy + NumCast + Num + PartialOrd<Self> + Clone + Bounded {
const DEFAULT_MAX_COMPONENT_VALUE: Self = usize::MAX;
}
pub trait Pixel {
}
pub trait ColoredPixel: Pixel {
const COLOR_TYPE: ColorType;
} |
I proposed such a solution once. It's one of the cleanest solutions I had come up with. I don't recall why we decided against it at that time, but I think it's a great solution. I'll go on and push some changes with this strategy next |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the PR is in pretty good shape at this point
+1 from as well, with my one outstanding nit and @fintelia 's review resolved. The CI should be fixed if you merge or rebase to the current master . |
The tests pass on my machine. Nearly all the checks in the workflow fail immediately though. For example, here is one of the errors:
Now doing a clean compile on my machine.... |
There was an upgrade to |
This pr is against the Merging from master to this branch may break the pr, I fear, as it might undo changes made in the |
We had merged |
I merged your master into this pr by hand and to my surprise it still compiles and the tests still run. However, I can't push it, as merging master into this pr modifies I don't think there is any way for this pr to merge, other than you merging master into next. The difference between master and next is more than 40 files, next is 43 commits ahead and 112 commits behind master. I can't see how it would be a clean solution to merge master into this pr with such a big difference between next and master. |
I think we're at the stage were we should probably be merging |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM then. I'll have a look resolving the merge madness here if it requires maintainer priviledges. @fintelia Unfortunately the master
branch has already diverged from the msrv/stability promises so no easy final release. We could make a backport branch with the most prominent bugfixes like in previous versions.
👍 In that case, seems to just be a matter of getting all the merges to go through so everything ends up on |
I can imagine it could be rather confusing for users to publish partial float support - exr supports it, but there's not much else you can do with floats. Don't we want to wait for this pr before releasing? |
It seems github auto-closed this as a consequence of the base branch being removed. Good thing it warned me about this. Not. Anyways, I wanted to rebase it as #1585. However now I need to find all other PRs that were auto-closed.. |
Discussion wanted
Adds F32 support to the DynamicImage.
Points to be discussed:
grayscale(image)
returnsLuma<T>
, butLuma<f32>
isn't a supported color type, so...f32
images will panic?impl GenericImage for DynamicImage { type SubPixel = u8; }
is difficult for float images, as it is unclear howf32
colors should be converted tou8
colors. Maybe the default subpixel type should bef32
for best quality, instead ofu8
?color.invert()
result is unclear when the color containsf32
values, because themax_value
of a float color component may not be knownEq
&Hash
for dynamic image by declaring allNaN
values to be equal? I don't think so.f32
support fortrait Pixel
:- for conversions like
Rgb<u8>::from(Rgb<f32>)
, we must assume the float range to be0..1
. Tonemapping is definitely too much for this.Todo:
next
?impl Pixel for Rgba<f32>
version
field to the new deprecation attributes(couldn't resist to add other changes as well, they are of course to be discussed)