Skip to content

fix: clamp log scale for negative/zero values, add symlog scaling, and add contrast-aware ticks to colorbar#47

Open
patrickoleary wants to merge 2 commits intoKitware:masterfrom
patrickoleary:ui/symlog-colorbar-ticks
Open

fix: clamp log scale for negative/zero values, add symlog scaling, and add contrast-aware ticks to colorbar#47
patrickoleary wants to merge 2 commits intoKitware:masterfrom
patrickoleary:ui/symlog-colorbar-ticks

Conversation

@patrickoleary
Copy link
Copy Markdown
Member

@patrickoleary patrickoleary commented Apr 15, 2026

Clamp log scale for negative and zero values, add symlog scaling, and add nice color-appropriate ticks to the color legend.

Addresses #18

@patrickoleary patrickoleary force-pushed the ui/symlog-colorbar-ticks branch from 7af37a1 to 0af8ee5 Compare April 16, 2026 10:55
@patrickoleary patrickoleary force-pushed the ui/symlog-colorbar-ticks branch from 0af8ee5 to d370e18 Compare April 16, 2026 12:16
raw_ticks = np.array(powers)
elif scale == "symlog":

def transform(x, th):
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.

Why are you making snap, transform and inverse closures?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I thought transform and inverse are pretty simple and only used in snap. and I think snap falls through like it was a private method, but all could be private methods so it's up to you.

Copy link
Copy Markdown
Collaborator

@jourdain jourdain Apr 17, 2026

Choose a reason for hiding this comment

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

Since they don't use sibling variable, I think it is better to have them defined once rather than recreating them each time the main method execute.

ctf = self.lut.GetClientSideObject()
self.config.effective_color_range = ctf.GetRange()

self.config.lut_img = lut_to_img(self.lut)
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.

Don't you want to capture the image when it is still linear?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I don’t think so. lut_img is meant to reflect the actual LUT state that the mapper will use, including inversion and any log / symlog remapping, not the intermediate linear preset.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

no it is not linear, it is either linear, log, or symlog, depending on the branching before you hit line 178.

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.

This is what I'm talking about

Screenshot 2026-04-17 at 4 38 08 PM

Copy link
Copy Markdown
Collaborator

@jourdain jourdain Apr 17, 2026

Choose a reason for hiding this comment

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

You see the picture/colors does not change, but the ticks do.

Which also mean that when you reduce the number of colors, they need to be evenly spread on the non linear scale.


self.render()

def _apply_linear_to_lut(self, invert=False):
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.

Maybe those methods could be in some other module so you can use them in both view_manager(2).py

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I was thinking that view_manager2.py would be moved to view_manager.py once you fixed the issues. I can't imagine both living for an extended period. the methods won't get reused after that.

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.

Ok so that means the ticks are linear (to some extent)?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

huh? I think this is a new topic.

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.

I think the comment Ok so that means the ticks are linear (to some extent)? was related to the image linear generation part... I don't know why it is showing up here... Sorry... Airport reviews ;-)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

_apply_linear_to_lut simply applies the preset again. and yes the interpolation is always linear between control points on the presets.

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.

I was thinking that view_manager2.py would be moved to view_manager.py once you fixed the issues. I can't imagine both living for an extended period. the methods won't get reused after that.

Correct, but since there was one working and the other one not working during the rendering weirdness. We currently have a flag that let you pick one or the other. I actually don't know how long I want/should to keep both.

@jourdain
Copy link
Copy Markdown
Collaborator

I think the code looks pretty good and it looks like we could merge it and iterate from that point on.

But maybe, let's centralize those new color handling helpers first.

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.

3 participants