Skip to content

V0.4.0#44

Merged
Ticqi merged 14 commits into
mainfrom
v0.4.0
May 27, 2026
Merged

V0.4.0#44
Ticqi merged 14 commits into
mainfrom
v0.4.0

Conversation

@Ticqi

@Ticqi Ticqi commented May 22, 2026

Copy link
Copy Markdown
Collaborator

Closes #43 and #39

Hi Lynn,

This PR contains:
(1) Fix ValueErrors raised by rgb_to_hsv when sampling colors outside [0,1]
(2) Fix demo notebook
(3) Small changes on readme and docs

The Problem in (1)

If the texture space is (H,S,V) we need to transform, the colors also need to be in (H,S,V) for adding the texture.
If colors are sampled with values outside [0,1] this causes problems since the clipping is only performed at rendering and rgb_to_hsv produces errors for value outside [0,1].

Solution

We now clip before transformation to (H,S,V) and only transform if necessary if the color space is already (H,S,V) we use the original (H,S,V) values directly to avoid unnecessary back and forth transformation.

Validation

I added a test to check that multiple combinations of color and texture values and color spaces produce images without errors.

@Ticqi Ticqi requested a review from LynnSchmittwilken May 22, 2026 08:53
@Ticqi Ticqi self-assigned this May 22, 2026

@LynnSchmittwilken LynnSchmittwilken left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

can you add a warning when values are being clipped, otherwise looks great and works for me!

Comment thread deadleaves/deadleaves.py

# Compute AABB, clip to canvas, query live tiles
y_min, x_min, y_max, x_max = leaf_mask_kw[self.leaf_shape].bbox(params) # pyright: ignore[reportCallIssue]
y_min, x_min, y_max, x_max = leaf_mask_kw[self.leaf_shape].bbox(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Minor, but why the line breaks?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

With the comment the line was too long, so my auto-formatting changed it

@Ticqi Ticqi merged commit 4f19133 into main May 27, 2026
8 checks passed
@Ticqi Ticqi deleted the v0.4.0 branch May 27, 2026 07:27
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.

Color sampling not cliped for color transformation correctly

2 participants