Friday, February 12, 2010

log2lin and lin2log in Photoshop

Some time ago I wrote a couple blog posts about working with Log images in Photoshop and how you can convert them to 32-bit linear for saving out as OpenEXR. It involves a little bit of Photoshop trickery unfortunately, but it works and you can set up actions and scripts to do it in one step, which I'd recommend.

One oversight on my part, however, was not describing how to go from 32-bit linear back to 16-bit Log. It's similar to doing the log2lin steps in reverse, but not quite. So, starting with a good looking 32-bit linear image...

1) Use the Cineon Converter to apply a lin2log operation to each layer. Typically you'll use the default settings, but switch the conversion to lin2log. After you do this, your image will look bright and washed out because it's been converted to Log space but is still getting the gamma correction Photoshop does to all 32-bit images. Don't worry.

2) Here's the tricky part. We have to convert back to 16-bit without Photoshop changing any pixels. During this mode switch, Photoshop converts your linear 32-bit image into whatever color space is set as your default RGB working space. So you have to go into the Color Settings dialog and temporarily change that to the linear color profile you've previously created.



3) Now change the image mode from 32-bit to 16-bit. Thanks to the previous steps, your pixels will now be in 16-bit Log space. When asked about Exposure and Gamma, leave those values untouched (0.0 exposure and 1.0 gamma). The image will not look any different (which is always the preferred behavior for switching image modes) and the pixels will not change values because of that linear profile.

3.5) You probably don't want a linear profile as the default working space, so change your Color Settings back to their original values, usually with sRGB as the default RGB working space. You probably notice this is kind of a pain - all the more reason to script it via JavaScript and Actions.

4) Open the Assign Profile dialog and assign a better profile to this image. If you apply sRGB (or tell Photoshop not the manage the document), you will see the image in Log space. You may also choose another profile to do some sort of film preview, such as the Theater Preview profiles that ship with After Effects.

And that's it. You should be able to start with a 16-bit Log file, use the various steps to convert it to 32-bit linear, use these steps to convert it back to 16-bit log and arrive at exactly the same image you started with, which is always an important test for any color pipeline.


For the record, you're not crazy if you have a 32-bit linear workflow but want to paint in log space. For one thing, many of Photoshop's tools aren't available in 32-bit (hello, Curves?!?). And some of the tools that are in 32-bit have not been appropriately tweaked for linear (I'm looking at you, Levels). Finally, if you have some film preview profiles, Photoshop can't use them in 32-bit mode like After Effects can.

So by painting in Log, you 1) reclaim some of your favorite tools, 2) can use film preview profiles, and 3) can still paint overbrights because 100% white in log space maps to 13.52 in linear. But be careful! Realize that layers will composite in Log space differently than in linear space, especially if you have soft feathered edges or use transfer modes such as Screen. If you flatten your layers before converting to 32-bit this won't be a problem, but if you need the layers to be separate, make sure you test everything first.

Thursday, December 31, 2009

ProEXR 1.5 Beta

Well, 2009 was quite a year. Just before it's over, we have a public beta of ProEXR for Photoshop to try out here.

It's been completely re-written to read and write EXRs as fast as possible, taking advantage of all the memory you've got on your system (including you 64-bit Windows users).

There's also a new "ProEXR EZ" plug-in for people who find the whole multi-layer EXR thing a little overwhelming but want the extra control ProEXR gives you over alpha channels. ProEXR EZ even lets you put the Alpha in the Channels palette, if that floats your boat.

Most users will want to have either regular ProEXR or ProEXR EZ installed, not both. But if you do install both and open a file, ProEXR will be used unless you force EZ in Photoshop's Open dialog. When saving, you can easily pick one or the other.

Please send in bug reports and comments so we can make this the most solid release yet!

Tuesday, November 18, 2008

Cineon Converter for Photoshop


This free plug-in fills a missing link in the Photoshop film production pipeline. It applies Kodak's standard log2lin transfer function to a log Photoshop layer, such as one you might get from opening a Cineon file. This is the same operation found in Nuke, Shake, Fusion, and the After Effects Cineon Converter.

In order to convert a log Photoshop document to a linear one:

1) Convert the document to 32-bit floating point, without altering pixel values.

2) Apply the Cineon Converter to each layer.


The Cineon Converter can be scripted using Photoshop Actions. A sample JavaScript is included showing how to automatically apply an Action to each layer in the file.

Once linearized, your Photoshop document is ready to be saved into a linear floating point file format (can anybody think of one?) and brought into your favorite compositor in the proper color space.

Enjoy!

Download



Wednesday, October 1, 2008

ProEXR ships with After Effects CS4


OK people, this is big, real big.

It's been officially announced: the free OpenEXR plug-ins I've been shipping for over a year are now going to be appearing in the next version of After Effects! So no longer will you have to replace Adobe's plug-in with the fnord one, because they will be the same! EXtractoR and IDentifier will also be included. You can read more about it here, here, here, and here.

And since you asked, yes, they will be remaining open source, and yes, I will continue to update them on the fnord web site as necessary.

Not included in After Effects will be the Comp Creator, which you can still download. And of course, the ProEXR Photoshop plug-in is separate.

This is really a big honor, and I want to thank the AE team for making it happen. I have had a love affair with After Effects for many years and it's hard to believe my plug-ins are now a part of it. Pinch me!

Update: See my credit in the AE secret about box (hold down option/alt while doing About After Effects). Whee!


Tuesday, September 30, 2008

exrdisplay for After Effects

When you work with linear floating point images in virtually any program, the standard conversion from the linear color space to your screen is usually some sort of gamma curve, a standard image operation. But a trained eye may notice that in some cases, OpenEXR files appear slightly differently. One example is the thumbnail previews shown by Mac OS X. In this case, the curve used is from ILM's exrdisplay program. In the sample below, standard gamma is on the left and exrdisplay is on the right:

Notice how in the exrdisplay version, the sky is not completely blown out. Overbright pixels have been brought into range and do not clip as harshly as they would with a standard gamma curve. ILM is using a modified gamma function and added an adjustable "knee" to make this happen.

Ordinarily this different curve was only of passing interest to me, but then I was helping out some friends put together a pipeline for an Inferno, and found that it also uses this curve, which made it necessary to replicate the same color operation in After Effects, which made me write this plug-in:

It has all the same controls as the exrdisplay command-line program, in addition to a few extras. For one thing, the dithering that exrdisplay always uses is optional in the plug-in.

But more interestingly, I've included a checkbox to apply the inverse function. This means you can take a regular image such as a JPEG and convert it to linear space using this plug-in, with control over the knee which will push some brighter pixels into overbrights. And then when you use the plug-in on the other end with the same settings, all values will round trip.

Anyway, I needed this for my personal use, so thought I'd share. Enjoy!

Download
Mac | Win

Friday, September 12, 2008

ProEXR 1.3 released

A new version of ProEXR is available, adding a key feature that has been requested by users. Whereas the Photoshop plug-in already had a mechanism for effecting the way alpha channels were handled, we've now bumped the feature out of Easter Egg land and into legitimacy via a shiny new dialog.



The dialog does not appear by default. As before, you access the feature by holding down the option (Mac) or alt (Win) key. But now the settings are made clear as day and you can change the defaults to whatever you like. You can even make the dialog appear every time if you crave more modal UI interaction than you're currently getting.

ProEXR 1.3 also includes a variety of other small fixes. Needless to say, we recommend everyone switch to it (without any upgrade fee, of course). Enjoy!

Tuesday, May 6, 2008

Converting to 32bpc in Photoshop Without Altering Pixels

Many people have a problem with color management. They think that when they open a JPEG in Photoshop, the pixels in the file should be the pixels that are shown on screen, but this is often not the case! If you have an sRGB image being viewed on your Mac monitor, Photoshop will darken the display pixels to show what the file would look like on a true sRGB monitor. Even if you think there's no ICC profile for the image, Photoshop will use the working space designated in Color Settings (usually sRGB). In general, this is probably what you actually want, but some people find it unsettling.

In another attempt to force users to do the right thing, Photoshop insists that all 32 Bits/Channel (floating point) images use a linear profile. When you convert your 8-bit sRGB image to 32-bit, Photoshop will linearize the pixels while simultaneously assigning a linear profile. The net result is that the image looks the same, even though the pixel values have changed. Again, this is usually what you want.

Except what if you don't want the pixels to to change, other than get converted to a higher bit depth? It is possible to do this, but it involves tricking Photoshop a little. I'll explain below.

To start, we'll take the famous Marcie image. This is a 10-bit Cineon file in Log space. Photoshop will open it as a 16-bit file without a profile (which means it uses your RGB working space). Marcie is a useful example for us because many film users still paint on Log images.

If you set the Photoshop Info Palette eyedropper to 32-bit mode and sample the grey LAD patch, you'll see values of 0.435 for that area. Now convert this file to 32-bit mode and sample again. Even though the image does not appear to have changed, the LAD patch is now reading 0.159. As mentioned above, the pixels have been darkened while the profile was linearized.

To convert from 16- to 32-bit mode without the change, revert to the original file and follow these steps:

1) Assign a linear profile (Edit > Assign Profile…) that you've previously created. When you do this, the image will appear much brighter, but using the info palette you can verify that the LAD patch is still 0.435. The Assign Profile function doesn't alter pixel values, only how they are displayed.

2) Now convert to 32-bit mode. The image will appear unchanged, which is to say too bright. But when you sample the LAD patch, you'll see that it has retained its value of 0.435. Photoshop usually converts from whatever profile you're using to a linear profile, but because we told it we already had a linear profile, no change takes place.

3) Your pixels are now in floating point Log space. If you save this image to an OpenEXR file, most file readers will assume linear space and brighten the image as Photoshop is doing. It will be up to you to make sure the Log pixels are treated properly in whatever program you're sending them to.

While Photoshop always defaults to using color management, there is a way to turn it off. By going to View > Proof Setup > Monitor RGB (make sure View > Proof Colors is also on), Photoshop will treat the file like is has the same profile as your monitor, so no transform will take place. In the above example, this would show pixels in Log space. You can also use View > 32-bit Preview Options to view a file with Gain and Gamma in 32-bit mode.

This workflow is currently being used in production by film studios who want to paint in Log, but export an OpenEXR file using ProEXR.
The part of the equation that is really missing is a way to convert from Log to floating point linear in Photoshop so that the EXR can have its proper linear values. Hopefully one day there will be a way to do this.

Update: Now there's a way!