# What is the transfer function for DNG monochrome images?

**Benhut1**Apr 4, 2017 10:32 PM

So I have finally figured out how to create linear raw monochrome DNG images that Photoshop can actually load (me trying to figure out how to do that was the topic of this thread What are the minimum required tags for a DNG file? ) but now I notice something unusual. Photoshop (or at least the Camera Raw plugin) doesn't use the transfer function I was expecting to convert linear raw monocrhome values to standard grayscale values that are ready to be displayed. I assumed that it would use the gamma 2.2 transfer function (like that used in sRGB and sGray color spaces), but it doesn't. Instead, it uses something drastically different. After creating a test monochrome DNG image with dimensions 256x256, and bit-depth of 16bpp, I loaded it into Photoshop with the Camera Raw plugin. For the Camera Raw settings, I disabled all of the raw processing options (Exposure, Contrast, etc controls on the "Basic" tab, all set to 0, and all sharpening and noise reduction values on the "Detail" tab, also set to 0), and the Process (on the "Camera Calibration" tab) set to "2012 (Current)". The test image had one pixel at each possible 16bit value, so that for the entire 256x256 image, all possible 16bit values were in present.

After loading it into Photoshop, I then proceded to convert it to Grayscale (since it loads as an RGB image, even when it's a monochrome DNG image file). I then saved it as an uncompressed TIF file, and used a hex editor to extract just the portion of the file that was the bytes of image data and saved this to a new file (I couldn't save as raw image byte array from Photoshop directly, because I'm using Elements). I then wrote my own program that compared those values, to the the linear raw values, and graphed the resulting curve. This allowed me to visualize the transfer function that Photoshop was using. I also did the same thing with the sRGB/sGray transfer function (which is a piece-wise function that is very close to being output=input^(1/2.2) but not quite, where part of it is a power function, and part of it is linear), as well as the actual gamma function with output=input^(1/2.2). I displayed all 3 of these curves on the same graph, and was amazed at just how FAR AWAY the Photoshop monochrome DNG transfer function was from the standard gamma function. Sadly, I don't know the actual equation used here, and I just hope that it isn't proprietary. I was able to get a fairly close approximation to it by using the ATan (inverse tangent) function. The equation I came up with that approximates it is:

output=ATan(input / 8986.905) * 45684.399

And the fact that the main function of ATan happens to work I found just by trial and error. I also tried various power functions and logarithms. I don't think the actual function Photoshop is using is based on ATan, it's just that ATan closely mimics Photoshop's transfer function here. If somebody here knows the actual transfer function that Photoshop uses for converting monochrome linear DNG image files to standard grayscale images, please let me know.

And by the way, I've included a picture of the graph that I had generated showing 3 different transfer functions.

The black line is the one Photoshop is using.

The red line is the the sRGB/sGray transfer function

The blue line is the power function: output=input^(1/2.2)

And here's the comparison of Photoshop's transfer function, and the transfer function I came up with after about an hour or two of trying different base functions and different values for multipliers.

The black line is the transfer function that Photoshop is using

The red line is the one I came up with after an hour or two of trial and error: output=ATan(input / 8986.905) * 45684.399

Again, if anybody can tell me what transfer function Photoshop is using here, please let me know. Thanks in advance.