Skip to content

feat(image): color channel mask#428

Merged
Tom94 merged 1 commit intoTom94:masterfrom
PedroVillegas:image-channel-mask
Mar 9, 2026
Merged

feat(image): color channel mask#428
Tom94 merged 1 commit intoTom94:masterfrom
PedroVillegas:image-channel-mask

Conversation

@PedroVillegas
Copy link

Hi Thomas,

I recently found out about tev and have found it to be very handy. The only thing I felt was missing: a color channel masking feature which lets me isolate individual, or multiple, color channels.

Note: I don't have an apple device to make and test changes for the metal shader, so I didn't.

@Tom94
Copy link
Owner

Tom94 commented Mar 8, 2026

Hi Pedro, thanks for the PR!

tev can already explode the channels of the currently selected group into individual ones via Ctrl+X. This'll work even when the group isn't made up of RGBA like this PR assumes it to be. But... that feature is not very discoverable; just an entry in the keybindings help window. I assume you didn't see it before working on this PR?

Viewing group subsets is also possible, although admittedly quite a bit more cumbersome: use e.g. tev :R,G image1.png image2.png ... to load just the red and green channels of your images.

So, with these features in mind, I feel like a better approach to the PR would be to

  • Add a GUI button for doing what Ctrl+X currently does, and
  • (optionally) make it work with subset selection, e.g. using a GUI similar to what the current PR has, but generalized to the current channel group rather than hardcoded for RGBA. Also perhaps worth adding a toggle to make it apply to all currently-open images with the same channel group.
  • Possibly both in a popup to avoid clutter. Especially since the current channel group can have arbitrarily many channels in it.

Compared to a pure shader-level approach, that'll also ensure that the histogram tracks the masked channels & that saving via Ctrl+S stays faithful to what's shown.

@PedroVillegas
Copy link
Author

Ah, I wasn't aware of the explode channels keybind. Though, the lack of multichannel groups is not ideal and the alternative you pointed out to expose multichannel groups seems like a hassle to use.

For now I'll just use this solution whilst I find the time to implement the changes you suggested.

@Tom94 Tom94 force-pushed the image-channel-mask branch 2 times, most recently from 057a6e8 to ef577ce Compare March 9, 2026 06:54
@Tom94 Tom94 marked this pull request as ready for review March 9, 2026 06:57
@Tom94
Copy link
Owner

Tom94 commented Mar 9, 2026

I thought about this some more and figured that the feature would actually be nice-to-have as-is after all, my bad. Reason being that shader-level channel masking does behave a bit differently from the channel ungrouping feature the more I think about it.

I made a few small changes and will merge after CI is through:

  • Using pure type traits / concepts for bitset overloads (no macros needed)
  • Removed special casing on alpha being the only visible channel (that's achievable with the X shortcut; I felt like it'd be nice to have the pure masking behavior at one's disposal as well)
  • Inverted the GUI toggle behavior (toggled == masked away)
  • Added a GUI button for ungrouping (X behavior) to the right of the RGBA mask buttons
  • Use Channel::color(name) instead of hardcoded color values
  • Made Ctrl+C and Ctrl+S respect the mask
  • Implemented the macos shader

Co-authored-by: Thomas Müller <git@tom94.net>
@Tom94 Tom94 force-pushed the image-channel-mask branch from ef577ce to 009e7c1 Compare March 9, 2026 07:15
@Tom94 Tom94 merged commit 2eb6270 into Tom94:master Mar 9, 2026
5 checks passed
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