Friday, November 28, 2014

Black and white conversion in Photoflow

If you search on the internet, you will find tutorials describing dozens of different methods  for converting a color digital image to grayscale (or "black and white" as many people say). There are lots of web pages that describe the grayscale conversion techniques and the theory behind them, so I decided not to go through all the details here... others have done that much better than I would.

However, if you are new to the subject and you need a good introduction, one of the best places you can visit is Patrick David's blog post at pixls.us. There you will find a very clear explanation of the technical background as well as a detailed description of the methods I'll discuss in this post, so I really encourage you to have a look there before continuing...

Generally speaking, we can say that the goal of grayscale conversion is to create "volume" out of "color", or in other words to translate the colors into reach tonal variations. There are of course lots of artistic exceptions to this rule, but I think that the basic idea is there...
However, there are lots of (infinite?) ways to translate a given "color" into the corresponding shade of gray, and which one is "the best" depends in most cases on the personal taste and on the image itself. You'll have to experiment a lot to find your personal "signature". The software must help you by providing several different options that can be quickly and easily compared on your screen.

One of the main goals I had in mind when I started coding PhotoFlow was to provide a good set of grayscale conversion tools, with all the flexibility that is usually found in high-end software. This means not only different conversions methods, but also the possibility to blend different channels together in separate layers, and access to Lab and CMYK channels in addition to RGB.
Of course it is too early to say "mission accomplished", but things seem to be on good track, and this post will try to show what can be done at the moment of writing.

Photoflow provides three main categories of grayscale conversions:
  1. straight desaturation: there are four methods available, owever each method is not configurable
  2. channel mixer: one of the most classic methods for grayscale conversion, it gives a lot of flexibility
  3. Pat David's black&white film presets from G'MIC: they emulate the spectral response of several widely used B&W films.
All grayscale conversion tools in PhotoFlow generate output images that are in the same colorspace as the colored original. For example, if you start from an image in the AdobeRGB colorspace, the grayscale version will still be an RGB image in AdobeRGB colorspace. Thus, you can for example easily add some toning or duo-toning without having to convert your image back to RGB...

Let's now see each tool in some detail.

Desaturation methods

The desaturation tool in photoflow is a close match of the one you can find in GIMP, and provides the same three grayscale conversion methods: LIGHTNESS, LUMINOSITY and AVERAGE. There is a very detailed explanation of the formulas behind those three methods in Patrick David's tutorial, with many examples of how colors are converted to grayscale in the three cases, so I will not repeat all the arguments here.

To apply the desaturation tool to a color image, you have to add a new layer and choose "Desaturate" in the "Color" group of the tools chooser dialog (see below).



Once the new layer is added, the corresponding configuration dialog will open automatically and will let you choose the desaturation method through a selector widget. You can at any time access this dialog by double-clicking on the name of the corresponding layer.



Photoflow provides a fourth method that has no GIMP counterpart: "L channel (Lab)". As the name of the method indicates, it uses the L channel of the Lab colorspace to convert colors to grayscale. The Lab encoding is the result of long scientific studies of the human perception of colors, and the L channel is designed to provide the closest match of how the human eye translates colors into perceived "lightness". If you want to learn more about the Lab colorspace and the theory behind, the wikipedia page could be a good starting point.
Another nice advantage of the L channel is that it is "perceptually uniform", in the sense that the L values are encoded in a way that reflects the natural response of the human eye. For example, L=50% corresponds to  a well-exposed 18% grey patch, which is usually called "mid-gray".
Technically speaking, in photoflow the L channel is extracted by first doing a colorspace conversion from the input profile to the Lab colorspace, then filling the a and b channels (which encode the color information) with 50% gray, and then converting the resulting greyscale image back to the original colorspace.

The images below show the result of the different desaturation methods compared to the original color image. For this comparison I have used the same portrait image that you will find in Patrick David's tutorial (with the author's permission), so that you can eventually compare with the examples shown there. At least to my taste, the L channel conversion gives the best tonal variations, particularly in skin areas, followed by the luminosity one. The other two (lightness and average) give results that are globally flatter.


Whitney by Patrick David (cc by-sa)
Mouseover type to see: Original - Lightness - Average - Luminosity - Lab L channel


This last conversion method is also the only one that gives always the same result independently of the colorspace in which the input image is encoded. To understand that, we need to introduce a bit of color management theory...

RGB, colors and color spaces...

Many people think that RGB values represent colors... however, this is not entirely true. RGB values are sort of meaningless if you do not specify the colorspace in which they are encoded. For example, a typical caucasian skin tone is represented with quite different RGB values in the sRGB and ProPhotoRGB colorspaces, and this has some consequences on the grayscale conversions discussed above. For example, the picture below lets you compare the result of a "lightness" desaturation applied to the same image encoded in sRGB and ProPhoto. As you can see, the tonality in the skin areas changes quite significantly...

Mouseover type to see: sRGB - ProPhotoRGB



The only exception is the desaturation based on the "L channel", because in this case the whole conversion is performed by taking color management properly into account. Hence, the grayscale version will look the same independently of the input colorspace, making your workflow more "predictable". In all other cases, you should consider to convert all your color images to a reference colorspace before desaturating, to have a uniform starting point for all your edits. In photoflow, it is just a question of adding a "colorspace conversion" layer below the desaturation.
Choose the RGB colorspace that gives you the best results, and stick with it all the time... you have been advised.
As a rule of thumb, sRGB will give you the larges tonal differences between Red and Green on skin tones, while large-gamut colorspaces like ProPhoto will bring the Red and Green channels closer to each other.
Another interesting choice is the LstarRGB colorspace, because its tone curve is encoded the same way as the L channel of Lab.Therefore, a well-exposed 18% gray patch will be represented as R=G=B=50% in LstarRGB, which makes in my opinion the use of curves and other tonal editings more intuitive...

Enough theory for this post, let's go back to practice!

The channel mixer

PhotoFlow includes a simple implementation of the channel mixer. The tool is not as complete as the one found in other programs, but it is sufficient for converting images to grayscale with great flexibility. Again, for a detailed description of how the channel mixer works I encourage you to read this post before continuing.

The channel mixer tool is activated like usual: you have to add a new layer and select the "channel  mixer" in the "Color" tab of the tool selection dialog. Once the layer is added, the configuration dialog of the channel mixer will show up automatically and will let you control how the RGB channels get mixed to produce the grayscale result.



For the moment, the channel mixer only creates grayscale images. Moreover, the multiplicative coefficients of the three channels are automatically scaled so that they sum-up to one, thus avoiding any shift of the overall image brightness. However, the coefficients can be set to values larger than 100% (up to 200%) or negative (down to -200%).


Hue + channel mixer adjustment

The channel mixer is very flexible and powerful, but playing with the individual RGB multipliers is sometimes long and tedious before one reaches the optimal result. There is however a nice technique that allows to dramatically change the result of the channel mixer using just one slider. The idea is to add an HUE adjustment layer below the channel mixer, which is then kept at its default setting of R=100% G=0% B=0%. Once you are in that configuration, you can significantly change the tonality of the red channel by simply shifting the hue of the color image thoward positive or negative values. As you can see below, you can improve a lot the constrast of your image or turn your model into a dangerous alien... you have been warned!



Mouseover type to see: Original - Hue = -90 - Hue = +90



G'MIC B&W Film Presets (from Patrick David)

The last conversion technique that I'm going to discuss is based on the amazing film presets prepared for us by Patrick David and included in the G'MIC processing library.

I've already written a detailed blog post on how to use the film presets in PhotoFlow, so I suggest you to read it here if you are not familiar with them.
In this case, we need to select the "Emulate Film [B&W]" item in the "G'MIC" tab f the layer chooser dialog s shown below.


Once you hit the Ok button, you will be prompted with the preset configuration dialog, where you can choose the actual film brand to emulate. In the example below, I've choosen the "Ilford Delta 400" preset.


Final considerations

That's all for this post. It's now time for you to do your own experimentations... you should also keep in mind that the techniques I've shown here can be further combined in lots of different ways: since they are applied as adjustment layers, you can play with layer opacities, blend modes and masks to further refine your conversions. There is almost no limit to what you can do...

No comments:

Post a Comment