The "Meet the GiMP!" ForumGIMP, Image Processing (DIP) and PhotographyImage Processing SoftwareScripts, Plugins, Python, Perl and SchemeSharpening in LAB colour space
Pages: [1] 2   Go Down
Print
Author Topic: Sharpening in LAB colour space  (Read 5508 times)
rayadagio
Script Magican in Residence
Lives here ;-)
***
Posts: 363



View Profile WWW
« on: December 06, 2008, 12:05:12 am »

As I just read in Welcome to Oz, "the best way to sharpen an image is in the LAB color space, sharpening the Lightness channel and not the A and B channels." I couldn't resist to write a script that is doing this job. It is a very simple script, but perhaps it is usefull. You don't have to decompose and recompose the image manually. The used sharpening tool is the unsharp mask. Only the edges will be sharpened in the hope that noise won't increase.

Menu location: <Image>Filters/Enhance/LAB Sharpening

Regards,
Bert


EDIT: Oh, Rolf already visited LABland! I will look at episode 55 soon to learn more about this strange region. :-)

* LAB Sharpening.py (2.12 KB - downloaded 223 times.)
« Last Edit: December 07, 2008, 02:44:34 pm by ray adagio » Logged

Please feel free to correct my unique usage of the English language! ;-)

www.rayadagio.de

monoceros84
Administrator
Sr. Member
***
Posts: 1452



View Profile WWW
« Reply #1 on: December 06, 2008, 11:21:58 am »

Mmhh, is Luminosity in the LAB space something different than Value in the layer modes? I always copy the last view into a new layer, set it to Value and do the sharpening there.
The advantage is that you won't sharpen CAs or colour noise...
Logged

Cheers,
Mathias

Visit this site about my photography, my experiences in Norway and my blog:
http://www.gedankenquirl.de (German language)

Rolf
Administrator
Sr. Member
***
Posts: 1325


View Profile
« Reply #2 on: December 06, 2008, 12:25:05 pm »

There is quite a difference between the both. HSV is a different representation of RGB, while LAB has this "human factor" in it. But GIMP can not (up to now) convert between them without considerable losses. Cinepaint and The Other Program have also losses while converting, but with 16 or more bit you don't notice them.

Here I have a RGB image, the L and V channels and a comparision of the histograms. L has more fine details, V the harsher contrasts.



* RGB.jpg (38.96 KB, 600x402 - viewed 223 times.)

* L.jpg (26.68 KB, 600x402 - viewed 229 times.)

* V.jpg (39.81 KB, 600x402 - viewed 214 times.)

* histo.jpg (14.22 KB, 552x312 - viewed 225 times.)
Logged

rayadagio
Script Magican in Residence
Lives here ;-)
***
Posts: 363



View Profile WWW
« Reply #3 on: December 06, 2008, 12:34:40 pm »

Very interesting comparison! Seems to be better to do the sharpening in V-channel until GIMP knows 16bit. There are only 4 characters to be changed in the script. I will try it soon.
« Last Edit: December 06, 2008, 12:57:05 pm by ray adagio » Logged

Please feel free to correct my unique usage of the English language! ;-)

www.rayadagio.de

Rolf
Administrator
Sr. Member
***
Posts: 1325


View Profile
« Reply #4 on: December 06, 2008, 01:11:41 pm »

Perhaps you can compare some results of both approaches?
Logged

rayadagio
Script Magican in Residence
Lives here ;-)
***
Posts: 363



View Profile WWW
« Reply #5 on: December 06, 2008, 01:24:41 pm »

Yes, I will do it. Regrettably short of time this weekend. For now the alternative script.

* HSV Sharpening.py (2.12 KB - downloaded 171 times.)
« Last Edit: December 07, 2008, 02:45:04 pm by ray adagio » Logged

Please feel free to correct my unique usage of the English language! ;-)

www.rayadagio.de

monoceros84
Administrator
Sr. Member
***
Posts: 1452



View Profile WWW
« Reply #6 on: December 06, 2008, 02:02:35 pm »

Hey, thanks. Especially for the histogram comparison!!!
Logged

Cheers,
Mathias

Visit this site about my photography, my experiences in Norway and my blog:
http://www.gedankenquirl.de (German language)

rayadagio
Script Magican in Residence
Lives here ;-)
***
Posts: 363



View Profile WWW
« Reply #7 on: December 07, 2008, 02:32:09 pm »

This is a first comparative test of 3 sharpening methods using unsharp mask:

-   unsharp mask without channel selection
-   unsharp mask applied in the L-channel of LAB colour space (LAB sharpening script)
-   unsharp mask applied in V-channel of HSV mode (HSV sharpening script)

If you tell me which layer shows the best result, I will tell you which method was used ;-)
The orders of used approach vary in both linked images.
In all layers the same settings were used for the unsharp mask: radius = 2, amount = 3, threshold = 1. Probably you could find better settings. The top layers’ opacities were set to 100.

Looking forward to your voting,
Bert

Images: www.rayadagio.de/STest.zip
(2 images, xcf-format, zipped - 151 MB  Shocked Huh)

Logged

Please feel free to correct my unique usage of the English language! ;-)

www.rayadagio.de

Rolf
Administrator
Sr. Member
***
Posts: 1325


View Profile
« Reply #8 on: December 07, 2008, 05:24:11 pm »

Tough task! The differences are subtle and nearly each layer has has advantages.... 
Logged

monoceros84
Administrator
Sr. Member
***
Posts: 1452



View Profile WWW
« Reply #9 on: December 07, 2008, 07:17:28 pm »

STest1:
1 and 3 don't show that much difference but 1 has some halos that are not visible in 3. So 3 is better.
2 is overdone in my opinion. It also decreases contrast. It removes noise a bit but the overall impression is worse than in 3.

STest2:
B is really overdone. It adds details that are not even in the original image. E.g. shadows at the letters on the cup.
A and C don't show that much difference but C is a little bit better in my opinion because it doesn't emphasize the CAs that much.

So I would say the layers 3 (STest1) and C (STest2) are the best.

Looking forward to the result Smiley
Logged

Cheers,
Mathias

Visit this site about my photography, my experiences in Norway and my blog:
http://www.gedankenquirl.de (German language)

rayadagio
Script Magican in Residence
Lives here ;-)
***
Posts: 363



View Profile WWW
« Reply #10 on: December 07, 2008, 08:10:39 pm »

I agree to you both, Rolf and Mathias. On the one hand the differences are really marginal. Barely relevant if the image fits to the window. On the other hand in 100% viewing there are some varieties. I'm really amazed, Mathias, my preferences are  e x a c t l y  the same as yours!

Here's the answer to the problem (sharpened channels bold):

STest1
3 -> RGB
2 -> LAB
1 -> HSV

STest2
C -> HSV
B -> LAB
A -> RGB

Sharpening in L-channel indeed seems to suffer from conversion losses in Gimp. The result is more grainy, reduces saturation in STest1 and shows some artifacts on the cup's glaze. The letters on the cup are best sharpened by RGB-sharpened version, the wall in the first image shows more details in the filigree parts in the HSV-sharpened version. The advantages of RGB vs. HSV seem to depend on the image. But you don't do anything wrong if you decide to use either the one or the other regularly. Let's wait for Gimp supporting 16bit processing and look if L-channel-sharpening can outperform in future.
« Last Edit: December 07, 2008, 08:17:51 pm by ray adagio » Logged

Please feel free to correct my unique usage of the English language! ;-)

www.rayadagio.de

monoceros84
Administrator
Sr. Member
***
Posts: 1452



View Profile WWW
« Reply #11 on: December 07, 2008, 09:38:50 pm »

Thanks for this great test! Not even that I learned something important (sharpening is one of the most important steps in my eyes). I also got the confirmation that the methods I used up to now are not that wrong. Always good to know Wink

If somebody is using a program that supports 16bit (as PS or Cinepaint) it would be really interesting to confirm or to reject our results. Maybe somebody can help?
Logged

Cheers,
Mathias

Visit this site about my photography, my experiences in Norway and my blog:
http://www.gedankenquirl.de (German language)

Rolf
Administrator
Sr. Member
***
Posts: 1325


View Profile
« Reply #12 on: December 07, 2008, 10:45:06 pm »

I'll try it in Cinepaint. And perhaps get it on the show on Tuesday.

Logged

paul
Just in
*
Posts: 11


View Profile WWW
« Reply #13 on: December 19, 2008, 02:13:59 pm »

It is interesting that you bring this up here.  There were three articles in the latest digital photography special magazine published by heise (https://www.heise.de/kiosk/special/ct/08/08/) mentioning that you really should use sharpening in the Luminance channel. One of the articles mentioned that only the Value channel of HSV was usable for this, other article mentioned the Luminance challen of LAB, too.

Not sure if this makes much difference as you will adjust the sharpening strength depending the selected channel. The decisive point here is that you sharpen only using Luminance/Lightness preventing colour fringes or anything similar.

Of course you will get halos using the L-channel, too. But there is a nice way to sharpen a photo in the Value/Luminance channel without decomposing it:

copy the layer, sharpen it (a bit more than wanted), put it in "Value" mode over the original layer and adjust the amount of sharpness using the opacity slider. This method is mentioned by monoceros84, too. It does not matter by the way if you are using here the layer copy in value mode or a gray tone copy of the luminance/value (which you like more) in value mode.

To prevent halos, there is another nice way. Keep in mind that halos are disturbing much more if they are bright as if they are dark. "Dark halos" are almost harmless. Create two copies of the photo to sharpen (to prevent to sharpen the colours I think you'll achieve the best results using the black and white Luminance/Value channels). Sharpen both of them using the unsharp mask (exaggerate a little bit). Set on of those layers to "Darken only" and one to "Lighten only". Now you can control the "dark and light halos" as you wish using the opacity channels.

Using only the darkening mode sometimes gives a bit strange light. So I recommend (in most cases) to use the lightening mode, too, but with definitely less opacity to prevent bright halos.

Another idea: You can do this with two sharpened layers in value mode (as explained above), too, giving to one of the layers a grayscale copy of the image itself as layer mask and to the other one a inverted (negative) grayscale copy.

P.S.: Ah, and, of course, don't forget to add a mask preventing the noisy areas of your photo of beeing sharpened, if there are. Using the last "idea" I am mentioning here this would result in creating a mask for the mask... :-)
« Last Edit: December 19, 2008, 02:18:40 pm by paul » Logged

Rolf
Administrator
Sr. Member
***
Posts: 1325


View Profile
« Reply #14 on: December 19, 2008, 02:23:16 pm »

I wanted to read these articles before making the show 80. Well, I think there will be more sharpening in 81. ;-)
Logged

Pages: [1] 2   Go Up
Print
Jump to: