PDA

View Full Version : Guide: Photoshop Grayscale Conversion Shoot-Off


hyperfinite
June 12th, 2010, 12:45 AM
This is kind of a precursor to a larger project I'm currently trying to figure out and develop in time for TAD, but since I've found limited useful information on this subject after needing a way to obtain color accurate grayscale values, I thought I'd develop a quick little guide for grayscale conversions in Photoshop, which can be summed up as follows:

While Photoshop has many methods to convert your images to grayscale, nearly all of them fail to replicate the anticipated values.

I decided to test out how accurate all the various methods of grayscale conversion I'm aware of are: I made a copy of an image on a separate layer, converted it to grayscale with whatever intended method or process, and converted it back to color by placing the original image layer on top of the grayscale layer with the blending mode set to color. By turning the visibility of the grayscale image on and off, the accuracy of the values can be checked.

The methods I tested consist of the Desaturate command, the Hue/Saturation tool, Black&White tool with sliders set to default, auto, and 50%, changing the image mode to Grayscale, neutral solid fill layers set to the Color or Saturation layer blending modes, and the Sponge tool. In retrospect, I somehow forgot to test the channel mixer, however I'm almost certain it's wrong as well.

I've provided a couple of gifs documenting the results of this for each of the different methods, and as you can see, the results are pretty abysmal: none of Photoshop's built in conversion methods obtain accurate values, although removing saturation through the vibrance adjustment is the least bad of the bunch. Also of note is that converting a color image to grayscale mode slightly changes values as well: at first I was hard pressed to see the difference, but it does change the midtones and shadows a shade.

So far I've been able to verify only one (two really, but they do the same thing) way to obtain proper grayscale values from a color image in CS5: create a new layer on top of the image you want to convert to grayscale, fill it with any neutral shade, and set the layer blending mode to either color or saturation. In CS4 and prior, using the Sponge tool to desaturate seemed to work as well, however it appears to give inconsistent results in CS5 regardless of whether vibrance is checked or not, and probably should be tested further or avoided.

In conclusion, it's really unfortunate that with so many different methods to convert images to grayscale and after twenty years, Photoshop still really only has one method that works.

Kerami
June 12th, 2010, 05:00 AM
I don't really know what you mean by "accuracy" of the values as grayscale conversions are only accurate in the context of an intended purpose or color model.

http://i46.tinypic.com/sxdq40.jpg
Source: http://en.wikipedia.org/wiki/HSL_and_HSV

The results also depend on the color mode you're working in, as the math is different between RGB and Lab.

The "Color" blending mode is based on the Lab color model (using HSL saturation rather than HSV) and only gives mathematically accurate results in Lab color mode. (GIMP uses HSL lightness for this set of blending modes)


For getting accurate HSV and HSL brightness, there is a legacy plugin called HSBHSL. For getting Lab luminance, a conversion to Lab color mode gives accurate results, although the Luminosity blending mode and some of the desaturation tools use Lab luminance and so do the same thing just within the context of the RGB color mode. If you wanted to deconstruct an image so that you could reconstruct it using the Color blending mode, you would have to use the Lab tools in Lab mode for best results, although RGB is doable. You can always convert back though.

As for RGB channel average, you could probably do that with Calculations Add or the Add blending mode, but neither of them seem to give mathematically accurate results, not sure if they fixed that in CS5.

The various tools one can use within PS to desaturate an image use different color models and it is indeed poorly documented. The main reason is that Photoshop's primary purpose isn't mathematically accurate image processing. I believe last time I checked, applying a black-white gradient map uses Lab, Hue/Saturation uses HSL, Desaturate uses Lab, blending modes use Lab, not sure about vibrance and others.

Also about the saturation thing, I believe to have heard that Photoshop uses an internal definition of saturation that is neither HSL, nor HSV or Lch, but it is very close to HSL in terms of results.

hyperfinite
June 13th, 2010, 05:41 PM
I don't really know what you mean by "accuracy" of the values as grayscale conversions are only accurate in the context of an intended purpose or color model.

http://i46.tinypic.com/sxdq40.jpg
Source: http://en.wikipedia.org/wiki/HSL_and_HSV

The results also depend on the color mode you're working in, as the math is different between RGB and Lab.

The "Color" blending mode is based on the Lab color model (using HSL saturation rather than HSV) and only gives mathematically accurate results in Lab color mode. (GIMP uses HSL lightness for this set of blending modes)


For getting accurate HSV and HSL brightness, there is a legacy plugin called HSBHSL. For getting Lab luminance, a conversion to Lab color mode gives accurate results, although the Luminosity blending mode and some of the desaturation tools use Lab luminance and so do the same thing just within the context of the RGB color mode. If you wanted to deconstruct an image so that you could reconstruct it using the Color blending mode, you would have to use the Lab tools in Lab mode for best results, although RGB is doable. You can always convert back though.

As for RGB channel average, you could probably do that with Calculations Add or the Add blending mode, but neither of them seem to give mathematically accurate results, not sure if they fixed that in CS5.

The various tools one can use within PS to desaturate an image use different color models and it is indeed poorly documented. The main reason is that Photoshop's primary purpose isn't mathematically accurate image processing. I believe last time I checked, applying a black-white gradient map uses Lab, Hue/Saturation uses HSL, Desaturate uses Lab, blending modes use Lab, not sure about vibrance and others.

Also about the saturation thing, I believe to have heard that Photoshop uses an internal definition of saturation that is neither HSL, nor HSV or Lch, but it is very close to HSL in terms of results.

Specifically, by accurate grayscale values I mean ones derived from a perceptually accurate luminance channel that roughly conforms to the tonal values we perceive colors as having, as opposed to an uncorrected geometric model that is mostly perception ignorant. For more information, the Handprint (http://www.handprint.com/HP/WCL/color11.html) guide on tonal value is a good starting point for the perceptual relationship between hue and value.

By using what Adobe calls the "HSL blending modes" in RGB, Photoshop is apparently using a Rec. 709/sRGB (or some derivative form of RGB) Y'CbCr color model for blending, which is more accurate than the internal model that appears to be an uncorrected HSL bi-cone variant of some sort. For our purposes, Photoshop uses the Y' luma channel to calculate value, which is visually accurate enough within RGB. While not as accurate as the LAB luminance channel, this should be sufficient for RGB work and is a huge improvement over most other grayscale transforms that Photoshop has to offer.

Most of the other grayscale conversions are based around the internal HSL bicone model: in particular Black&White, Hue/Saturation, and Desaturate are all transforms of this internal model. I'm not sure what models the Sponge tool and grayscale mode use in CS5, although I'm fairly certain there aren't any LAB derived transforms outside of LAB color space.

Photoshop's HSL modes are not derived from the LAB color model, internally or directly at least. It is more accurate to say that the Rec. 709 Y'CbCr standard was developed from the same body of knowledge CIE used to develop LAB, and was also designed to be approximately similar to human eye perceptions, which accounts for the similarities between the two color models. This distinction is important because the luminance channels between the two are different: LAB's luminance channel is more accurate when working in LAB color, and the Y'CbCr luma channel produces accurate enough values within RGB. In their respective color spaces, they're both usable for the most part, but they're calculated differently and should not be thought of as being interchangeable.

Indeed, it appears when working in LAB color, the HSL blending modes should be avoided for the most part since they introduce Y'CbCr derived colors. Ironically, neither the desaturate command or the HSL blending modes accurately reflect the LAB luminance channel and both appear to be derived from the same RGB based Y' channel.

Additionally, I noticed another obvious method of generating perceptual accurate grayscale values from the luma channel that I missed: set the original color image layer to luminosity and place it on top of a neutral solid fill layer.