Dehalo and Amount Slider

Moderator: jsachs

tomczak
Posts: 1367
Joined: April 25th, 2009, 12:56 am
What is the make/model of your primary camera?: Fuji X-E2
Contact:

Dehalo and Amount Slider

Post by tomczak »

Quite impressive already - how is the detection done, more or less?

It appears that the Amount slider works somewhat differently than I expected - rather than blending Input with Output, it seems to display the input image when Amount = 0 and the full Output image for any other value.

Also, could you please comment on how Halo Threshold and Difference Threshold differ from each other? I took the former as the halo contrast limit and the latter as the width limit, but I'm not sure.
Maciej Tomczak
Phototramp.com
jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Dehalo and Amount Slider

Post by jsachs »

The Amount behavior sounds like a bug -- will check it out for the next release.

When removing light halos, it samples in a series of directions around each pixel, looking for a pattern of 4 pixels where the central pixel is the lightest, a step above is a little darker, a step below is the darkest, and a step below that a little lighter. The theory is that a halo will lighten one side of an edge and darken the other. The radius controls the step size (halo width). The method for dark halos is similar.

The halo threshold is the required difference between the two inner samples (the darkest and lightest). The difference threshold is the required difference between the two outer samples.
Jonathan Sachs
Digital Light & Color
tomczak
Posts: 1367
Joined: April 25th, 2009, 12:56 am
What is the make/model of your primary camera?: Fuji X-E2
Contact:

Re: Dehalo and Amount Slider

Post by tomczak »

Cheers!

Not sure if this is right, but if the convention for threshold sliders is that all the way to the right is the full application of the transformation without restrictions, the thresholds in the Dehalo seem reversed?
Maciej Tomczak
Phototramp.com
tomczak
Posts: 1367
Joined: April 25th, 2009, 12:56 am
What is the make/model of your primary camera?: Fuji X-E2
Contact:

Re: Dehalo and Amount Slider

Post by tomczak »

Do both thresholds have to be met for the central pixel to be classified as the edge of a halo?
Maciej Tomczak
Phototramp.com
jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Dehalo and Amount Slider

Post by jsachs »

Yes, both conditions have to be met. This means the difference must always be positive or zero.
Jonathan Sachs
Digital Light & Color
Marpel
Posts: 692
Joined: September 13th, 2009, 3:19 pm
What is the make/model of your primary camera?: Nikon D810
Location: Port Coquitlam, British Columbia

Re: Dehalo and Amount Slider

Post by Marpel »

Was about to ask a question about DeHalo and found this thread....so....

I must admit confusion on this tool, particularly as related to the Difference Threshold, and perhaps some words being used in the above explanation.

I presume that a Halo can be more than 4 actual pixels in width, so when the explanation references "pixel", it is actually referring to a "distance" that may be in single pixels or multiple pixels. Is that correct? If this is not correct, that means any Halo will only be 4 pixels wide?

In your explanation, you describe how the tool looks for a pattern around a central pixel. Does that mean, in the case of a Halo which is along a vertical edge, the tool looks in all directions, determines that there is insufficient difference vertically, so ignores that and concentrates on the horizontal differences, thus identifying the vertical Halo?

And, can you explain what actually happens to the samples "a step above is a little darker" and "a step below that a little lighter"? Are these the pixels which actually represent the true tones and which the tool copies to replace the real dark and real bright pixels, so they are "evened out"? In other words, a mountain against a brighter sky, the tool samples the mountain and uses it to replace the darkest side of the edge and samples the sky to replace the brightest side of the edge. If not, what is their actual purpose?

Marv
jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Dehalo and Amount Slider

Post by jsachs »

Halos are detected and remove one pixel at a time.

The algorithm operates on one pixel at a time in the input image. For each pixel, it looks at 4 samples of the input image in each of 16 different directions, trying to locate the strongest halo it can find in any of the directions. The 4 samples include the central pixel and a sample 2 radii in one direction and 2 and 4 radii in the opposite direction. It then analyzes and scores each direction, looking for the one that produces the greatest score. A direction is rejected if the pixel pattern indicates no halo is present based on the relative brightness of the 4 samples. Otherwise, (for removing light halos) the score is the difference between the central pixel and the one below it plus the difference between the one above and the one 2 steps below. If all directions are rejected, no action is taken. If a halo is detected in some direction, the central pixel is replaced with the sample above it, effectively cloning out the halo.

The halo threshold relates to the required difference between the central pixel and the sample below it. The difference threshold relates to the require difference between the sample above and the sample 4 radii below.
Jonathan Sachs
Digital Light & Color
tomczak
Posts: 1367
Joined: April 25th, 2009, 12:56 am
What is the make/model of your primary camera?: Fuji X-E2
Contact:

Re: Dehalo and Amount Slider

Post by tomczak »

I think I almost understand now how the algorithm works and what the threshold sliders may be doing, but I still have a practical issue: I'm not sure how to use those sliders (along with radii) to target only the type of halos that I want to remove. The radius works fine to capture different widths of halos, but how to fine-tune the two thresholds to make good use of the sliders? - oftentimes they seem to almost do the same thing.
Last edited by tomczak on January 8th, 2023, 12:48 pm, edited 1 time in total.
Maciej Tomczak
Phototramp.com
tomczak
Posts: 1367
Joined: April 25th, 2009, 12:56 am
What is the make/model of your primary camera?: Fuji X-E2
Contact:

Re: Dehalo and Amount Slider

Post by tomczak »

Also, just an idea with the understanding that it may be beyond the scope or objectives of this transformation: it appears to me that while oversharpened images may show oversharpened spot details as well, it is the 'linear' nature of the continuity of the halos along outlines of larger shapes that makes them most objectionable - not so much if they are more 'spotty' and occur inside the relatively continuous tonal areas and those are also easier to confuse with actual contrasty details and textures. If this is true, I wonder if there is a way of influencing the search algorithm to somehow prefer these continuous halos at the perimeters...
Maciej Tomczak
Phototramp.com
jsachs
Posts: 4203
Joined: January 22nd, 2009, 11:03 pm

Re: Dehalo and Amount Slider

Post by jsachs »

As I mentioned when I first released the transformation, I am still working to improve the halo detection algorithm. I played around with detectors that look in the perpendicular direction as well as the gradient, but the result were not much better. Some variant oof this may still be promising. Another option is to clone more than just one pixel when a halo is detected.

Here is one way to use the sliders. First, set the display to halo map. Then, with both thresholds set to 0, adjust the radius to maximize halo detection, even if it over-selects some areas. Then increase the halo threshold until it starts to miss some of the halo, and finally increase the difference threshold until it starts to miss some of the halo. If you want, adjust the radius again and repeat.
Jonathan Sachs
Digital Light & Color
Post Reply