Sunday, April 14, 2013

Working With TIFF Files

Pentax Zoom-90, Fuji Superia ISO 800

I would like to give you a very brief overview about manipulating the TIFF Image File. "TIFF" is either an abbreviation for the Toronto International Film Festival, or Tagged Image File Format - we will be looking at the latter.

First of all, what is TIFF? Here is a technical page that should answer some questions, for those who  are deep into computing. I hardly understood a word of it to be truthful - all the talk about "Tags" and "Offsets" simply had me slack-jawed...

So here's the Dave Definition, intended for those of you who really know something about this to crap all over - please, PLEASE add your comments below - I don't get many comments here, and I want some!  Now is the day!

- TIFF is an uncompressed image file format which is quite old; it first appeared in the mid 1980's seemingly to provide some flexibility in creating files within Fax Machines. It is also capable of compression in a loss-less manner, meaning the file size can be reduced without compromising image quality (which is good). It is also capable of bit-depth of up to 32 bits (which is very good). Finally, it is "tagable" and this is the part I don't understand at all, but evidently, it means something along the lines that certain extra bits and bytes of data can be placed as needed within all the other data that makes up the lines and colours of the picture. I hate to ask - who wants to ad extra data, and how is it done?

Then a little light came on. You'll recall when we discuss the RAW files that are generated by "good" cameras are really not picture files at all, but rather all the data about the picture, for which special RAW conversion software is needed to generate a preview of the image, and allows very heavy manipulation to really enhance it's appearance, and finally exports the data as a real picture file (usually JPEG). Well, maybe, TIFF is a "meet you half way" kind of file which is a real picture file, but at the same time can be made to carry some extra data payload about the picture too.

Well then, whether I'm right or wrong, lets go with that. So, it turns out that my Epson V500 scanner puts out 8-bit or 16-bit TIFF files, as well as 8-bit JPEGs. I always keep it in 16-bit TIFF mode, so I've got plenty of samples to work with. But what are we dealing with here, really? To answer my question - "who adds the extra data tags?" The answer must be "my scanner", because it sure ain't me. "What is my scanner adding?" I have no idea. Finally, the only question that really matters  - "Do the data tags that my scanner is adding create any value to the final product?" Well, maybe, to a limited extent. So, I set out with a simple experiment. First, I scanned a specific image in JPEG mode, and here it is:

Epson V500 JPEG Scan

Next, I  scanned the same negative in TIFF-16 mode -

Epson V500 TIFF-16 Scan

The only difference I can see is slightly better contrast - look at the snow in the foreground, or at the trees against the cloudy sky - you'll see it there best. Also I should mention the JPEG file size is 4.3 MB, but the TIFF is 24.9 MB! A file size of six times bigger is hardly worth a little extra contrast, is it?

However, there is an up side, I think. When you import the TIFF into your image editing software (Lightroom, Photoshop, Photivo, etc.), it turns out that the TIFF format allows a better range of enhancement. Here are two TIF to JPG conversions I made using Photivo:

 Photivo Conversion #1 - Enhanced Dynamic Range

Photivo Conversion #2 - Enhanced Brightness and Contrast, Reduced Saturation

I especially like what happened in Conversion #2 - the detail really comes to life here. Also, I discovered what the "extra data tags" of the TIFF format output of my scanner might contribute to the process. I noticed things in Photivo such as, when trying to manipulate the JPEG file, the Gamma adjustment doesn't do anything, whereas with the TIFF format, Gamma works as it should. I noticed a couple of other similar things, where certain adjustments were far more effective with TIFF than with JPEG. But I expect these things would be quite dependant on to what degree the software is reading the data. Photivo is primarily a RAW manipulation and conversion package which provides full functionality of all its features with RAW files, and limited functionality with TIFF and JPEG. But then, GIMP does not work with RAW at all (except by way of a plug-in called "UF-RAW), but seems capable of massive manipulation of JPEG files in it's hundreds of Filters. GIMP also does a good job of converting 16 bit TIFF to 8 bit JPEG. Confused? So am I. But eventually, you get a feel for what works best, and you don't really need to know what's going on under the hood.

Finally, I want to bring up one more important discovery. My experiment verifies that when working with either Epson's TIFF or any JPEG files, you can "enhance" the look of a picture on your screen, but such enhancements are considered by some to be "destructive" in nature. I find this curious, that a picture can be made to really look better, but "under the hood", things are seemingly getting worse. I always notice what the histogram is doing while working with my images, and when doing any kind of "contrast stretch", which seems to make a picture look better, there is always what looks like a loss of data that happens, as clearly seen below:

 Photivo Histogram of TIFF File When First Opened

Same Histogram Showing "Comb Filter" After a Contrast Enhancement for Conversion #2

This only occurs when working on JPEG and TIFF, but not with RAW. It is important to realize that with a RAW file, enhancements can be made, over a much wider range, non-destructively. But to be fair, it's not exactly a destructive process with TIFF and JPEG either, although the Histogram might appear so at first glance. So what's really going on here?

Remember this particular example is a contrast enhancement. This will enhance a photo by making the bright highlights stand out, or "pop" against the pictures darker regions. Here, Photivo is selectively adding some "0" (black) values into the mix, and at the same time, adding some light peaks, which look like little noise spikes on the Histogram. There is a specific algorithm which the software dials in here, and it actually works quite well, although the Histogram looks as though data is being lost and noise is being added, it is being done in a way that results from the software's analysis of the picture. The result is that the rather dull looking untouched file ends up with well computed additions and subtractions designed to give a nice rich contrast stretch. 

Remember with JPEG especially, nothing can be changed in the original picture data, so to enhance a JPEG, the software has to add and subtract from the existing picture data. That's all it can do, and in many cases, the results are good enough. But with a RAW file, remember it consists of nothing but data, all of which can be changed, with no addition or subtraction relative to what is there or not there. Therefore, if you want to do some kind of contrast enhancement to a RAW file, the adjustments you make with your software while watching the picture preview can accomplish it in a far bigger variety of ways, none of which make the Histogram end up looking like a "comb filter". You are effectively "re-making" the picture from all of it's data building blocks, none if which are ever lost. But with JPEGs and to a slightly lesser degree , TIFF's, the true picture data can never be "remade" but only enhanced artificially.

This is great for digital cameras that create RAW files, but not so great for cheaper cameras which do not. It's also not so great for film cameras, because with film, there is no RAW file. Fortunately, film has the advantage of requiring little or no manipulation to look good, so the limited enhancement that can be done with JPG or TIFF are usually more than adequate, with TIFF seemingly having the advantage of it's built in "data tags" to allow a slightly greater variety of enhancements, but at the expense of a huge file size. 

I haven't written anything this technical for a long time, but I hope you found it helpful.

No comments:

Post a Comment

Reader's comments are welcome, and are subject to moderation by the author.