Project

General

Profile

Feature #11538

Add blend modes for Lab a-channel and Lab b-channel

Added by Andrew Martin over 2 years ago. Updated over 2 years ago.

Status:
Fixed
Priority:
Low
Assignee:
-
Category:
Darkroom
Target version:
Start date:
03/11/2017
Due date:
% Done:

100%

Estimated time:
Affected Version:
git stable branch
System:
all
bitness:
64-bit
hardware architecture:
amd64/x86

Description

Darktable already has the "Lab color" blend mode, however it would also be useful to have a separate blend mode for the a and b channels, that way a module could be applied to just a single channel. For example, if the b channel has a lot of noise, but the a channel does not, it would be useful to apply the lowpass module just to the b channel to reduce the noise.

lab-ab_vs_lab-color.png (421 KB) lab-ab_vs_lab-color.png Andrew Martin, 03/13/2017 06:17 AM
view_channels.png (494 KB) view_channels.png Andrew Martin, 03/16/2017 04:33 AM

History

#1 Updated by Ulrich Pegelow over 2 years ago

  • Tracker changed from Bug to Feature

#2 Updated by Ulrich Pegelow over 2 years ago

You can find an implementation of channel specific blend modes in pull request #1459. Please check. I am especially interested if this solves the issue for you as I don't want to populate the menues with needless blend modes. So I will only merge if this really makes a difference.

#3 Updated by Andrew Martin over 2 years ago

I built darktable from the branch you created with this feature implemented and it looks good! I am still learning how to use this blurring/sharpening technique (as instructed by Photoshop LAB Color by Dan Margulis, chapter 5), so I am still learning how to leverage this. In the book, he gives an example image with a lot of noise on the B channel. I pulled that into darktable and applied the recommended gaussian blur settings with the lowpass module:
  • left - b radius 7, a radius 4 (using the new a-channel and b-channel blend modes)
  • right - b and a radius 7 (using "Lab color" blend mode)
  • bottom - original image without blurring

The difference in this image is subtle, however the skintone appears to be more lifelike in the left version - would you agree? I'll keep looking for other images which would especially benefit from this technique. Also, would it be feasible to add viewing of each individual LAB channel to this request? That would help to identify where the noise exists in a particular image.

#4 Updated by Roman Lebedev over 2 years ago

Andrew Martin wrote:

I built darktable from the branch you created with this feature implemented and it looks good! I am still learning how to use this blurring/sharpening technique (as instructed by Photoshop LAB Color by Dan Margulis, chapter 5), so I am still learning how to leverage this.

In the book, he gives an example image with a lot of noise on the B channel.

As a raw file, or LDR? (jpeg / etc)
It is potentially much better to actually have the same comparison base available here.

I pulled that into darktable and applied the recommended gaussian blur settings with the lowpass module:
  • left - b radius 7, a radius 4 (using the new a-channel and b-channel blend modes)
  • right - b and a radius 7 (using "Lab color" blend mode)
  • bottom - original image without blurring

Did you try the proper 2-instance profiled denoise trick?

The difference in this image is subtle, however the skintone appears to be more lifelike in the left version - would you agree? I'll keep looking for other images which would especially benefit from this technique.

IMHO all three look like overly compressed/pixellated JPEG.

Also, would it be feasible to add viewing of each individual LAB channel to this request?

How would this even work?
Unlike RGB, where each channel can be interpreted as monochrome version of the image,
in lab i'd say only L can be viewed without a/b (or rather, with them set to 0.0)

Or the same idea applies; keep a, set b to 0.0, set L to 50.0?

That would help to identify where the noise exists in a particular image.

#5 Updated by Ulrich Pegelow over 2 years ago

however the skintone appears to be more lifelike in the left version

The differences are subtle but visible. I agree that there is some justification for channel specific blend modes.

Also, would it be feasible to add viewing of each individual LAB channel to this request?

Not anytime soon. That feature would require to visualize a certain color channel at an arbitrary space in pixelpipe. Let's say you want to see the a-channel in the lowpass module. We just cannot switch simply all subsequent modules off. That would lead to very strange and surprising effect. The only realistic way would be transferring the channel in question in parallel to the image data from the lowpass module up to the pixelpipe with all distortions being applied. We do something like this to make the mask visible on request by using the alpha channel. That could theoretically been done with other channels in a similar way but only alternatively to the mask. One would not be able to see an individual channel and the mask at the same time.

As Roman pointed out there is also the question of how to represent a channel. Obvious for L but not so for a and b. In it's simplest form all channels are simply mapped to [0; 1.0] as a grayscale image but that might fall short of usability...

Last but not least the question of the GUI. The reasonable place to add such a feature would be the blending operations, namely parametric masks which already deal with individual channels. The GUI of that part is already very cluttered and should not get even more complicated.

#6 Updated by Andrew Martin over 2 years ago

Roman Lebedev wrote:

Andrew Martin wrote:

In the book, he gives an example image with a lot of noise on the B channel.

As a raw file, or LDR? (jpeg / etc)
It is potentially much better to actually have the same comparison base available here.

He provides it as a psd, but I had to export it as a tiff in order to open it in darktable

I pulled that into darktable and applied the recommended gaussian blur settings with the lowpass module:
  • left - b radius 7, a radius 4 (using the new a-channel and b-channel blend modes)
  • right - b and a radius 7 (using "Lab color" blend mode)
  • bottom - original image without blurring

Did you try the proper 2-instance profiled denoise trick?

Can you elaborate? Do you mean just applying the "denoise (profiled)" module? The point that Dan Margulis makes is that sharpness typically occurs in the L channel, so for noise that occurs in the A and B channels, you can blur those channels to help get rid of the noise without affecting the sharpness of the image. This is what I did - apply a gaussian blur to both the A and B channels.

The difference in this image is subtle, however the skintone appears to be more lifelike in the left version - would you agree? I'll keep looking for other images which would especially benefit from this technique.

IMHO all three look like overly compressed/pixellated JPEG.

This was a purposefully bad image to start with so the amount of improvement will be modest at best.

Also, would it be feasible to add viewing of each individual LAB channel to this request?

How would this even work?
Unlike RGB, where each channel can be interpreted as monochrome version of the image,
in lab i'd say only L can be viewed without a/b (or rather, with them set to 0.0)

Or the same idea applies; keep a, set b to 0.0, set L to 50.0?

I think the way it works in Photoshop when you view a just the A or just the B channel is pixels of no color are set to 50% gray. The further they get towards either color in the channel, the more dark/light they get (lighter is more magenta, darker is more green).

Ulrich Pegelow wrote:

however the skintone appears to be more lifelike in the left version

The differences are subtle but visible. I agree that there is some justification for channel specific blend modes.

Also, would it be feasible to add viewing of each individual LAB channel to this request?

Not anytime soon. That feature would require to visualize a certain color channel at an arbitrary space in pixelpipe. Let's say you want to see the a-channel in the lowpass module. We just cannot switch simply all subsequent modules off. That would lead to very strange and surprising effect. The only realistic way would be transferring the channel in question in parallel to the image data from the lowpass module up to the pixelpipe with all distortions being applied. We do something like this to make the mask visible on request by using the alpha channel. That could theoretically been done with other channels in a similar way but only alternatively to the mask. One would not be able to see an individual channel and the mask at the same time.

What about just being able to view the channels before any of the modules are applied (except probably the input profile)? Maybe this makes more sense in the lighttable section. This way, you could assess what the image looks like on import to see where adjustments need to be made. For example, I've attached each individual channel of both RGB and LAB of this same sample image. Looking at the channels, you can quickly see that the majority of the noise occurs in B in RGB and B in LAB, so in each color space you know which channel you should focus on for noise reduction. This would avoid the problem of needing to figure out how to display the channel with the modules applied.

#7 Updated by Roman Lebedev over 2 years ago

Andrew Martin wrote:

Roman Lebedev wrote:

Andrew Martin wrote:

In the book, he gives an example image with a lot of noise on the B channel.

As a raw file, or LDR? (jpeg / etc)
It is potentially much better to actually have the same comparison base available here.

He provides it as a psd, but I had to export it as a tiff in order to open it in darktable

I pulled that into darktable and applied the recommended gaussian blur settings with the lowpass module:
  • left - b radius 7, a radius 4 (using the new a-channel and b-channel blend modes)
  • right - b and a radius 7 (using "Lab color" blend mode)
  • bottom - original image without blurring

Did you try the proper 2-instance profiled denoise trick?

Can you elaborate? Do you mean just applying the "denoise (profiled)" module? The point that Dan Margulis makes is that sharpness typically occurs in the L channel, so for noise that occurs in the A and B channels, you can blur those channels to help get rid of the noise without affecting the sharpness of the image. This is what I did - apply a gaussian blur to both the A and B channels.

The difference in this image is subtle, however the skintone appears to be more lifelike in the left version - would you agree? I'll keep looking for other images which would especially benefit from this technique.

IMHO all three look like overly compressed/pixellated JPEG.

This was a purposefully bad image to start with so the amount of improvement will be modest at best.

Also, would it be feasible to add viewing of each individual LAB channel to this request?

How would this even work?
Unlike RGB, where each channel can be interpreted as monochrome version of the image,
in lab i'd say only L can be viewed without a/b (or rather, with them set to 0.0)

Or the same idea applies; keep a, set b to 0.0, set L to 50.0?

I think the way it works in Photoshop when you view a just the A or just the B channel is pixels of no color are set to 50% gray. The further they get towards either color in the channel, the more dark/light they get (lighter is more magenta, darker is more green).

Ulrich Pegelow wrote:

however the skintone appears to be more lifelike in the left version

The differences are subtle but visible. I agree that there is some justification for channel specific blend modes.

Also, would it be feasible to add viewing of each individual LAB channel to this request?

Not anytime soon. That feature would require to visualize a certain color channel at an arbitrary space in pixelpipe. Let's say you want to see the a-channel in the lowpass module. We just cannot switch simply all subsequent modules off. That would lead to very strange and surprising effect. The only realistic way would be transferring the channel in question in parallel to the image data from the lowpass module up to the pixelpipe with all distortions being applied. We do something like this to make the mask visible on request by using the alpha channel. That could theoretically been done with other channels in a similar way but only alternatively to the mask. One would not be able to see an individual channel and the mask at the same time.

What about just being able to view the channels before any of the modules are applied (except probably the input profile)? Maybe this makes more sense in the lighttable section. This way, you could assess what the image looks like on import to see where adjustments need to be made. For example, I've attached each individual channel of both RGB and LAB of this same sample image. Looking at the channels, you can quickly see that the majority of the noise occurs in B in RGB and B in LAB, so in each color space you know which channel you should focus on for noise reduction. This would avoid the problem of needing to figure out how to display the channel with the modules applied.

I see. To me this really sounds like one of these things that should be done in proper layer-based image editor like GIMP, not in darktable.

#8 Updated by Andrew Martin over 2 years ago

What about the denoise modules in darktable? This technique allows you to use them more effectively, applying them just where they are needed. Or maybe the solution is just apply them with different blend modes using trial and error until you find the one that reduces noise the most with sacrificing the least detail?

#9 Updated by Roman Lebedev over 2 years ago

Andrew Martin wrote:

What about the denoise modules in darktable?
This technique allows you to use them more effectively,

applying them just where they are needed.

You mean drawn/parametric masks?

Or maybe the solution is just apply them with different blend modes using trial and error until you find the one that reduces noise the most with sacrificing the least detail?

I'm not sure what the question is

#10 Updated by Andrew Martin over 2 years ago

Roman Lebedev wrote:

Andrew Martin wrote:

What about the denoise modules in darktable?
This technique allows you to use them more effectively,

applying them just where they are needed.

You mean drawn/parametric masks?

I mean only applying them to the specific channel(s) where they are needed. If you can see that most of the noise occurs in the LAB-b channel, you can use the "Lab-b channel" blend mode.

Or maybe the solution is just apply them with different blend modes using trial and error until you find the one that reduces noise the most with sacrificing the least detail?

I'm not sure what the question is

If adding the ability to view each channel to darktable is not possible/practical, then perhaps a trial-and-error approach is the only way to find the best mechanism for reducing noise with sacrificing as little detail/sharpness as possible.

#11 Updated by Ulrich Pegelow over 2 years ago

Pull request #1459 adds an option to view individual channels. You activate that option by shift-clicking on the mask display icon in the parametric masks feature of a given module. By hovering over the respective parametric masks slider you activate the channel for display. All channels are mapped to a [0; 1.0] data range.

#12 Updated by Dominik Markiewicz over 2 years ago

Urlich,
I've found channels preview really useful, great change.
However, it's a bit harsh in usage. Two main problems I've found:
- I cannot see if I'm in 'normal' mode or in 'channel preview', because icon doesn't change. It would be great to indicate current mode somehow (maybe just change button icon or so?).
- When I try to adjust mask I tend to change between mask/channel preview quite often. This cause a lot of unnecessary mouse movements and clicks. Would be great to have hot keys to switch between this options. Or even simpler, there could be also one another preview mode: mask & channel preview at once - if you hover over slider, channel preview is visible, otherwise mask is visible.

#13 Updated by Ulrich Pegelow over 2 years ago

I cannot see if I'm in 'normal' mode or in 'channel preview', because icon doesn't change.

In fact it should change (at least with the latest commit in that PR). If channel/mask preview mode is active the icon gets highlighted. Maybe the change is too small and hardly visible.

Or even simpler, there could be also one another preview mode: mask & channel preview at once

Did you notice that you can combine mask + channel preview? Just do a shift+ctrl-click on the icon. I'll need to see if we can have a key shortcut so that altering preview modes can be done without going back to the icon.

#14 Updated by Dominik Markiewicz over 2 years ago

Ulrich Pegelow wrote:

I cannot see if I'm in 'normal' mode or in 'channel preview', because icon doesn't change.

In fact it should change (at least with the latest commit in that PR). If channel/mask preview mode is active the icon gets highlighted. Maybe the change is too small and hardly visible.

Oh... Most of icons have highlighted background (eg. color picker, mask on/off), this one's highlighted icon itself. And yes, It's hardly visible, I'd go to change this somehow to make this more noticeable :)

Or even simpler, there could be also one another preview mode: mask & channel preview at once

Did you notice that you can combine mask + channel preview? Just do a shift+ctrl-click on the icon.

No, I didn't. Probably this option also should be marked in tooltip. Anyway, that is something I'll definitely give a try.

I'll need to see if we can have a key shortcut so that altering preview modes can be done without going back to the icon.

I don't know if you have any expirience with Lightroom, but one quite usesfull thing there is `magic alt` key (https://digital-photography-school.com/lightroom-tips-develop-module-magic-alt-key/). This is probably far beyond simple hotkey mask on/off, but maybe in the future? :)

#15 Updated by Ulrich Pegelow over 2 years ago

I don't know if you have any expirience with Lightroom, but one quite usesfull thing there is `magic alt` key

In fact no experience with LR here, but - admittedly - that UI feature makes a lot of sense, more than my current solution. I'll see if I can come up with something similar.

#16 Updated by Andrew Martin over 2 years ago

Ulrich Pegelow wrote:

Pull request #1459 adds an option to view individual channels. You activate that option by shift-clicking on the mask display icon in the parametric masks feature of a given module. By hovering over the respective parametric masks slider you activate the channel for display. All channels are mapped to a [0; 1.0] data range.

I have not had a chance to build a copy of Darktable with this PR integrated yet, but it sounds good, thanks!

#17 Updated by Ulrich Pegelow over 2 years ago

I don't know if you have any expirience with Lightroom, but one quite usesfull thing there is `magic alt` key

I have implemented something comparable in PR 1459. If you hold down the shift and/or control key when entering one of the sliders in the parametric masks the channel display and/or mask display gets activated. Note that activating this feature only works on entering the respective slider, not when you are already have entered. When leaving the slider you get back to the previous state after some timeout. The timeout feature is there so that you don't get rapid status changes if you accidentally leave the slider and re-enter for a brief time.

#18 Updated by Dominik Markiewicz over 2 years ago

Ulrich Pegelow wrote:

If you hold down the shift and/or control key when entering one of the sliders in the parametric masks the channel display and/or mask display gets activated.

This is pretty cool! :)

Note that activating this feature only works on entering the respective slider, not when you are already have entered.

This would be probably a bit more intuitive if you could listen on key down/up events and activate mask if only gradient slider is used by user (ie, slider marker is selected & ctrl/shift buttn is selected -> show mask). This should eliminate need of the timer. However, I was not looking at the code yet, so I'm not sure how hard to implement it is.

#19 Updated by Ulrich Pegelow over 2 years ago

This would be probably a bit more intuitive if you could listen on key down/up events

Key up/down/left/right are already reserved in combination with shift and control. Key pressing moves the active slider and shift/control selects the step size (small, large). That's the same as for other sliders so any change to that would make it a mess in terms of usability.

BTW darktable only uses the meta/alt key for zooming. That's the reason why I don't want to give it an unrelated function in sliders.

#20 Updated by Ulrich Pegelow over 2 years ago

  • % Done changed from 0 to 100
  • Status changed from New to Fixed

#21 Updated by Andrew Martin over 2 years ago

Thanks for all of the work to implement this! I am looking forward to the next release!

#22 Updated by Roman Lebedev over 2 years ago

  • Target version set to 2.4.0

Also available in: Atom PDF

Go to top