Lossless compression. TIF.

vftt.org

Help Support vftt.org:

This site may earn a commission from merchant affiliate links, including eBay, Amazon, and others.

Neil

Well-known member
Joined
Apr 26, 2004
Messages
3,434
Reaction score
487
Normally I save my pictures as jpeg files but recently learned that with each save there is a loss of original data. If I wanted to use TIF do I need to configure my camera and shoot TIF's or is this done when (or after)downloading from camera to computer?
 
Neil said:
Normally I save my pictures as jpeg files but recently learned that with each save there is a loss of original data. If I wanted to use TIF do I need to configure my camera and shoot TIF's or is this done when (or after)downloading from camera to computer?
RAW format contains the full uncompressed data in your camera. I may be wrong in some (newer full featured camera) cases but I think the only choices most of us have at the camera level is jpg or raw. Raw format may be camera manufacturer specific and could require specialized plug-ins with your computer or printer processing software (e.g. Photoshop). Macs come with many of these pre-installed. Some additional information is available here.
 
Last edited:
You set your camera to save as TIFF.

Be aware that you will get substantially less images per card.
For example with my camera and a 128MB card set for:
JPG Fine-Large = 55 images
TIFF-Large = 10 images.
RAW =19 images.
If the subject is really important, I shoot RAW + JPG-Large = 14 images.
Nowadays, I shoot with a 1 or 2 GB card...


When editing JPG images, I always "save as" leaving the original intact.
 
Last edited:
you need to find out what your camera offers. "raw" files are the camera's best attempt to save its original bits, which varies from vendor-to-vendor and camera-to-camera.

jpg has several issues, only one of which is the lossy compression thing. the bits-per-color issue is another big one. The jpeg faq says standard JPEG is 8-bit color for each RGB (24bit total). If your camera has 10 or 12 or 14 or 16-bit analog-to-digital converters, the camera has to throw away some info before it can produce a JPEG. This leads to lower dynamic range, which sucks if you are trying to make high-contrast images. I forget what film's dynamic range is, I seem to remember it's something like 11-bit equivalent. I don't know what TIFF permits.
 
4000'er said:
When editing JPG images, I always "save as" leaving the original intact.
That is very good advice. When I download images off my camera, I save them to master folder and make them read only; I then burn them to a CD. Any images I want to edit only get copied from the master folder. I never edit the masters. I don’t shoot in RAW or TIFF format very often unless I know I want a very good image with subtle color changes (like a sunset) because the RAW and TIFF formats take up so much space.
 
Others have posted some nice detailed references:

Executive summary:
1. Your camera produces a raw image (frequently >8 bits/pixel/color). The characteristics of this image are highly dependent upon the characteristics of the sensor, etc. Some cameras can output this image as a raw file (format depends upon the manufacturer). No compression, big files. Philosophically, it is a bit like a film negative... (but it is a positive image).
2. The camera then processes the raw image to produce a corrected image (8 bits/pixel/color). (There is some loss of information in the correction process.) This can be output as a .tif file (no compression, ie lossless format--big files).
3. This corrected image can compressed and stored as a JPEG (.jpg) file. There is a quality parameter in this compression which allows one to trade off between image quality (ie lossy compression) and file size.

The ability to save raw and corrected images tends to be found on higher-end cameras. The purpose of the raw image is to allow the photographer to customize the processing, but it also requires that he process the image--you can't just take it and run like you can a JPEG file.

If your camera only saves JPEG files, set it so that it saves the highest quality image files possible. You can always postprocess them later to a create a smaller file (lower quality image) but you cannot recover the lost information. Any time you uncompress and recomress a JPEG image (or any lossy format), you will lose some information. Thus it is best that you always start from your original JPEG file. (BTW, there are image rotation programs that can rotate JPEGs 90, 180, or 270 degrees without de- and re-compression. In effect they just shuffle the bits and cause no loss of image quality and almost no change in the file size.)

BTW, Digital zoom is a waste of time--it simply selects a piece of the image. You can always do that later from a full-size image.

BTW2, TIFF files (.tif) can be compressed with lossless compressors, eg zip, gzip, bzip2. (You can compress any file with a lossless compressor and then get the exact original back. The amount of compression, however, varies tremendously depending on the characteristics of the file.) For instance a USGS topo in TIFF format compresses by a factor of 2 with gzip and a factor of 3 with bzip2. Probably less compression with a landscape image.

Doug
 
Last edited:
What hasn't been adressed in this thread is - does the loss of data *matter*? JPEG is rather cleverly designed to minimize loss of data that would be visible to the human eye. Next, bear in mind that printing your photos at 3x5, or viewing them on a computer screen, means sacrificing a great deal of data no matter which format you start from. Those losses, plus the differences between printers or between computer screens, are MUCH more significant than the difference between JPEG and TIFF or RAW in almost every case.
JPEG does produce certain artifacts if you look closely enough - "ripples" parallel to sharp edges, for instance, and a loss of very subtle color differences in variable areas like sky. (These artifacts become extremely obvious if you pick a low enough "quality" setting.)
Note that "TIFF is lossless" is not always true - TIFF allows several different compression schemes. Check that your TIFFs are created using "LZW" (or "raw/uncompressed"). (LZW is very likely what you've got by default.)
Shooting in RAW or TIFF may be worthwhile if you're planning to do a lot of post-processing (making things visible that weren't visible in the original shot, which JPEG might have felt free to discard), or if you think you might do a very large print. As others have mentioned, you pay a price in memory used.
Film dynamic range is at least [CORRECTED: 12 bit, which is equivalent to "36bit color" in computer graphics], probably more. I hadn't realized digital cameras might have more range in RAW mode; I always thought lack of range was inherent in the current generation of digital sensors. [Edit: Dougpaul has made this a little clearer.] I'll have to try it and see if there's a visible difference (and whether it's worth the extra work).
Ditto to what others have said about editing photos - make the original read-only, and save any intermediate versions in a lossless format like TIFF or XCF. But don't forget to convert to JPEG or PNG before putting the photo online - nobody wants to wait ten minutes to download a photo.

Edit: to clearly answer the original question:
"If I wanted to use TIF do I need to configure my camera and shoot TIF's or is this done when (or after)downloading from camera to computer?"

Either is possible and either can be a reasonable choice. Shooting in TIF mode captures more details from the scene (but takes a lot more space in your camera's memory). Shooting in JPEG and converting to TIF on your computer protects you against losses during repeated editing, which seems to be what you're more worried about.
If you shoot in JPEG mode, your camera will sacrifice some details (though I've suggested that you aren't likely to notice the difference). See DougPaul's post. Converting to another format after downloading JPEG to your computer won't bring those details back. However, if you edit your files on your computer, each time you save your changes in JPEG you are losing a tiny bit more data. Depending on the type of changes, this can quickly add up to a visible difference when you edit (and save) a file repeatedly. So if you plan to do significant editing, it's worthwhile to convert to TIFF once the picture is on your computer, even if you shot it in JPEG mode. (Of course, if you know you are going to do this, you will want to consider shooting in TIFF in the first place, if your camera permits it and you have enough room on your memory card.)
 
Last edited:
General concensus in the camera industry has decided that JPG is good enough for nearly everyone, the rest use RAW. Almost no cameras support TIFF anymore for good reason; if people want that much control they will want RAW which offers much more to the serious user. If they just want high quality images they will use highest quality JPG.

Aside from always saving images in the highest quality and never overwriting the original JPG, don't worry about it. For nearly all uses by mere mortals, you will never see JPG artifacts. In practice, there is almost no loss of information.

-dave-
 
DougPaul said:
BTW, Digital zoom is a waste of time--it simply selects a piece of the image. You can always do that later from a full-size image.
If you use RAW mode that would be true. Otherwise, there are circumstances when it's not true & digital zoom has some value, because the camera can (if the manufacturer chooses to take the effort) do the digital zoom before throwing away information:

(a) if the camera does a digital zoom from its raw data and then downgrades to 8-bits + JPEG compression (rather than the other way around)
(b) if you don't use the full # of pixels offered by your camera. For instance I have a 5MP camera that I always run in 3MP mode because 3MP is good enough for me & I'm cheap when it comes to harddrive space; digital zoom that uses the central 3MP of the image (approx 1.3x digital zoom) should be better quality than if I took a 3MP picture & resized by the same factor, and more convenient than if I took 5MP pictures & cropped the central 3MP myself.
 
A couple of small nits:

nartreb said:
Film dynamic range is at least 36bit (RGB - that's 12 bits per color), probably more.
The dynamic range is 12 bits for each of 3 colors. Not the same as 36 bits.
36 bits = 6871947673 levels
12 bits = 4096 levels

BTW, a bit is about a stop, to put it in photographic terms. (A stop is a factor of 2 in light intensity.)

The following search brings up a bunch of references on dynamic range:http://www.google.com/search?hl=en&q=image+"dynamic+range"+stops&btnG=Google+Search. The first pointer looks like a nice reference on the topic: http://www.normankoren.com/digital_tonality.html.

Shooting in JPEG and converting to TIF on your computer protects you against losses during repeated editing, which seems to be what you're more worried about.
Not needed. See below.

If you shoot in JPEG mode, your camera will sacrifice some details (though I've suggested that you aren't likely to notice the difference). See DougPaul's post. Converting to another format after downloading JPEG to your computer won't bring those details back. However, if you edit your files on your computer, each time you save your changes in JPEG you are losing a tiny bit more data. Depending on the type of changes, this can quickly add up to a visible difference when you edit (and save) a file repeatedly. So if you plan to do significant editing, it's worthwhile to convert to TIFF once the picture is on your computer, even if you shot it in JPEG mode. (Of course, if you know you are going to do this, you will want to consider shooting in TIFF in the first place, if your camera permits it and you have enough room on your memory card.)
Converting from JPEG to TIFF gains you nothing--some information is already lost. (Conversion from JPEG to (lossless) TIFF should lose nothing extra, but also cannot gain you anything.) Just save your original highest quality version of the image in whatever best format the camera provides, never modify the original, and work directly from said original whenever you produce some other version.

If you are doing something that requires multiple steps to produce the final result in a lossy format, use a lossless file format between steps to prevent unnecessay degradation.

Doug
 
Last edited:
David Metsky said:
For nearly all uses by mere mortals, you will never see JPG artifacts.

For reference, my current avatar has quite a few ' "ripples" parallel to sharp edges'. I had to shrink it quite a bit to make it into an avatar. Time to change it soon anyway! :D
 
DougPaul said:
BTW, Digital zoom is a waste of time--it simply selects a piece of the image. You can always do that later from a full-size image.

arghman said:
If you use RAW mode that would be true. Otherwise, there are circumstances when it's not true & digital zoom has some value, because the camera can (if the manufacturer chooses to take the effort) do the digital zoom before throwing away information:
True, if the manufacturer so chooses. I'd expect the biggest difference to be around the edges of the image and the overall difference to generally be rather small. The camera might also be able to choose a better exposure if you already know that you will only want to keep the center region. (I'll admit that I was trying to avoid filling my post with too many caveats...)

If the choice is to use a digital zoom vs an optical zoom to achieve the same final picture, the optical zoom will generally give better quality. (I'm taking the risk of leaving out the caveats about the optical quality of the lens at various focal lengths... :) )

FWIW, I don't think that I have even tested my digital zoom. Besides, my digital camera's minium focal length is only 35mm (35mm film equivalent) and my favorite outdoor lens is the 28mm (35mm film equivalent) wide angle on my film SLR...

A meta-comment:
There is a fine line in these discussions--the experts can include and debate the fine points with risk of losing/confusing the non-experts. There is value in both expert-only discussion and discussion aimed at non-experts.

Doug
 
Last edited:
nartreb said:
JPEG does produce certain artifacts

JPEG artifacts are easy to spot anytime you zoom in on the compressed photo.

nartreb said:
Note that "TIFF is lossless" is not always true - TIFF allows several different compression schemes. Check that your TIFFs are created using "LZW" (or "raw/uncompressed"). (LZW is very likely what you've got by default.)


Just to make sure we are on the same page. LZW is the lossless compression encoder. It is (use to be used) in the GIF standard and other places until the legal wrangling about its copyright and patent rights.

And as a sidebar, the JPEG spec has always allowed for saving the file in a lossless fashion. It just never seems to be implemented.

Keith
 
Last edited:
David Metsky said:
Aside from always saving images in the highest quality and never overwriting the original JPG, don't worry about it. For nearly all uses by mere mortals, you will never see JPG artifacts. In practice, there is almost no loss of information.
Mostly true if you keep to the higher quality settings on JPEGs. However, if you repeatedly compress and decompress an image (even at a high quality setting) the artifacts can build up, potentially to the point where they are noticable. This is certainly true in speech signal compression (my field) and can be very bad if you use different compression algorithms at different stages.

I will note that, particularly if I play with the the gamma (to increase the brightness) on my display to look at the darker portions of some of the trip pictures referenced here, I can sometimes see JPEG artifacts. People may have used less than the highest quality settings (to reduce the file sizes) on the images posted to the web servers. (I have also seen artifacts in some of my own original pictures in certain unusual situaitons. My camera only saves JPEGs.)

Doug
 
SAR-EMT40 said:
Just to make sure we are on the same page. LZW is the lossless compression encoder. It is (use to be used) in the GIF standard and other places until the legal wrangling about its copyright and patent rights.
There are other lossless compression algorithms. One could also design a lossless image compression algorithm which would presumably do a better job than one that does not know about the structure of images. PNG, which was designed in part to get around the LZW patents, is a replacement for GIF. It includes both lossless modes.

And as a sidebar, the JPEG spec has always allowed for saving the file in a lossless fashion. It just never seems to be implemented.
A guess based upon my general knowledge of the internals of the JPEG algorithm: such a file would be bigger than a simple lossless TIFF.

Doug
 
Last edited:
36bit vs 12bit
Mea culpa: my language was wrong. In computer graphics, phrases like "16-bit color" refer to the total bits used to describe a pixel in terms of three primary colors, Red, Green, and Blue. (RGB isn't the only possible way of describing colors, but let's skip that for now.) However, this apparently is not correct when talking about "dynamic range" - it seems to be understood that photographers use this phrase to refer to the bits used to encode the output of a single sensor, which is sensitive to only one color. In short, 16-bit color has only 5-bit dynamic range (6 for green).
While I'm correcting, I should have said something like "equivalent to" X bits - film doesn't use "bits" at all.


"If you are doing something that requires multiple steps to produce the final result in a lossy format, use a lossless file format between steps to prevent unnecessay degradation."

That's all I meant - my idea of "significant editing" is editing that takes enough steps where you might want to save your intermediate work in case of accidents.
 
Last edited:
DougPaul said:
A guess based upon my general knowledge of the internals of the JPEG algorithm: such a file would be bigger than a simple lossless TIFF.
Doug

I believe that would be correct except that they were smart enough to actually do away with the compression portion all together if the image was to be stored lossless so it was virtually like a RAW type format.

I am doing this without a net though i.e going by my memory on stuff I did 20 years ago. :eek: :D I used to do a fair amount of work with compression algorithms and image processing.


DougPaul said:
There are other lossless compression algorithms. One could also design a lossless image compression algorithm which would presumably do a better job than one that does not know about the structure of images.

There are others, RLE (not very sophisticated) pops to mind and I remember some others that I can't think of the algorithm names. The biggest advantage to the jpeg format and compression algorithm is that it is actually adjustable as to how much of a trade off you want to make between compression and quality. I can't think of another algorithm that gives you that flexibility. LZW and RLE certainly don't. At least not off the top of my head. But like I said, its been 20 years. :D

Keith
 
Last edited:
SAR-EMT40 said:
I believe that would be correct except that they were smart enough to actually do away with the compression portion all together if the image was to be stored lossless so it was virtually like a RAW type format.
The old cop-out for when one's "highly tuned" algorithm does a bad job...

Some general purpose compressors simply refuse to compress the file if the "compressed" version is bigger than the original.

I am doing this without a net though i.e going by my memory on stuff I did 20 years ago. :eek: :D I used to do a fair amount of work with compression algorithms and image processing.
I'm not as young as I used to be either... :)

Except, in this case, I read an article describing the internals of JPEG sometime in the last year.

There are others, RLE (not very sophisticated) pops to mind and I remember some others that I can't think of the algorithm names. The biggest advantage to the jpeg format and compression algorithm is that it is actually adjustable as to how much of a trade off you want to make between compression and quality. I can't think of another algorithm that gives you that flexibility. LZW and RLE certainly don't. At least not off the top of my head. But like I said, its been 20 years. :D
Run-length-encoding isn't of much use for photographs... OK for digitally drawn sketches, though. Digital drawings fill large areas with digitally constant colors--photos have variation on all distance scales.

2 lossless algorithms: Hamming coding is an old classic. Gzip and zip use LZ77 which is free of patent problems. Bzip2 (a standard Linux/Unix utility) uses modern arithmetic coding techniques, IIRC. http://www.bzip.org/.

Bandwidth compression for speech (one of my fields) is a mixture of science and art, image compression is probably similar.

Doug
 
Last edited:
Holy mega pixel! What a thread! You guys are amazing!

OK, here's the practical reason behind my question. I'm working on a guidebook and am taking pictures to put in it. I was told by a guidebook author to save my work in TIFF. I'm using a 6 Megapixel Canon A540 which I now know only saves in JPEG mode, neither RAW nor TIFF. I am concerned as to how well my images will come out on the printed page. I can batch convert all my jpegs to TIFF but doubt that that will improve the image quality in the book.
 
Top