Saturday, October 16, 2010

JPEG Noise & Artifact

In my previous article "JPEG Hell!" I show you how high JPEG compression in Paint Shop Pro can really damage your image file.

One of my young reader argued that he cannot see much damage when his image is being compressed in Photoshop, even at a very high compression / low quality setting.

He wonder if I can "show" him that JPEG in Photoshop really damage his original file!

Your wish is my command ;)

To do this demonstration I selected this "grab shot" I captured in K.L., 1998.

I was shooting a street market scene in Petaling Jaya, Malaysia, this kind Malay family let me used their veranda for an overhead view.

While I was shooting, at the corner of my eyes I saw her with the baby... quick shot with my EOS1n and 80-200 at about 200mm.

What can I say? Just pure innocent.

I was surprise how well the ISO 400 Kodak Ektapress negative film rendered her flawless complexion so well!

The colour negative was scanned with my Nikon Coolscan 4000 ED.

Now, back to our JPEG noise demo...


To see what's happening to our JPEG compressed image, we will use Photoshop’s “Difference Layer Blend Mode” which will look for differences between two layers.

When activated, any areas in both layers that are exactly the same appear as pure black, while areas that are different appear as strange coloured noise.

The Difference Blend Mode isn't used very often in our imaging work, but it does a great job of showing us how much noise and artifact we are adding to our JPEG images when we compress them!

Let me show you how...

After opening our image in Photoshop, in my case; I open the "Malay Girl & Baby" image you saw above. Next, bring out the "Layers" palette.

Next, by pressing Ctrl+J (Win) / Command+J (Mac)I now have two layers in the Layers palette - the original picture (the Background layer) on the bottom and a copy of the original, which Photoshop has named "Layer 1", above it.

With "Layer 1" selected, change the "Normal" blend mode to "Difference" (see red circle).

As you change the blend mode to "Difference", you will notice your picture window turn black! Don't panic :)

What Photoshop is telling me that both layers are in fact identical!

Let us be absolutely sure that all we are seeing now in the image is nothing but pure black.

To do that, we will use a “Levels adjustment layer”.

I will click on the “New Adjustment Layer” icon at the bottom of the Layers palette (the red circle again)... and select "Level".

This brings up the Levels dialog box with a Histogram. The Histogram see exactly what tonal information is being displayed in my image. If both of my layers (images) are identical, then all I should see in my Histogram is a single vertical bar on the far left, which just happens to be what I'm seeing!
I have just proven to you what you probably know, that when we make a copy of the image; the two are 100% identical.

What is the point of this exercise?

What we will do now is to replace that Layer 1 with a copy that has been saved in JPEG, quality 1 (the lowest quality and the highest compression).

To do that I had both pictures open, I change to the "Move" tool; select the Q1 copy and while pressing the Shift key, drag the Q1 image and drop it into the original.

This action will place the Q1 copy on top of the original (background) photo as Layer 1.

After I change to "Difference" mode and bring up the Level adjustment layer dialogue, this is what I get.

Notice, even though the picture window still look black; the Histogram (red circle) now show a thick black bar. It is telling us there is a DIFFERENCE between the two images!

To show where the differences are, we will drag the little white triangle on the right side of the Histogram all the way to the left (see clip below).



This is what you see:

Not nice, right? Those weird colours represent all the damage we have done to our image by compressing it.

The JPEG image is now filled with what are commonly known as "compression noise / artifacts", which is just a nicer way of saying "we took your perfectly good picture and messed it up for you"!

So what can we do about it? Unfortunately, not much really.

The JPEG format is still your best bet for saving digital photos, and when file size is an issue, we really have no choice but to compress them.

In Photoshop you can compress at a low compression and thus retain a high quality, IF you do not mind a larger file size.

As you can see from above, saving your image in Q12; do minimise damage to your image; the down side is that your 7.9 MB image is now 2.5 MB, not lower.

To me, that is not bad at all; a saving of 5 MB! At Q12, I tell you; it is so good you will NOT be able to see the difference! Don't the Histogram confirm that?

Now you know the point of this exercise! ;)

Famous Last Words:

I always shoot RAW and JPEG, some of my friends think I am "Kiasu"; so be it! But please answer me this:

In the bad-old film day, would you let a lab with exhausted chemical; process your precious films? Even you know the negatives will be damage but not destroy by the "bad" chemical?

In a nut shell that is what JPEG do to your files!

So what is the best compromise?

If you must shoot only JPEG, make sure your camera is set to the highest JPEG quality.

Once you upload the files to your computer, treat those files as your negatives; if you must work on them, use a duplicate. Leave the master JPEG untouched.

What about JPEG 2000?

I thought you never ask ;)

This is the same 7.9 MB file save as JPEG 2000, quality 90%; end file is 2.5 MB just like the JPEG Q12 but look at the Histogram! Virtually no noise!

If you feel comfortable using it, I would recommend it highly!

Looking at a 300% crop of the master file and a 5th generation JPEG Q7 file, may be Ken Rockwell is right; he don't care much about RAW file format!

His article of RAW v JPEG is a very informative read!

In more than 15 years the humble JPEG has come a long way!

2 comments:

Ira Dvir said...

Based on users feedback we have modified our HIPIX presets to include 14 levels instead of 5, going lower and higher in bpp. There was a chroma bug, which was fixed too. Anybody who downloaded the SW, just click on the update (under (?). Enjoy! www.hipixpro.com

cy.leow said...

Sorry Ira, I downloaded the new version and tested it; look and perform the same. Saved BMP image color still different from original JPEG.
May be I still get the older version?
It is NOT CLEAR what you meant by "click on the update (under?). There is no "update" at ?