Sunday, November 8, 2009

ImageJ--the step by step

1-Download imageJ from http://rsbweb.nih.gov/ij/. There are MAC, Linux, and Windows 32 and 64 bit versions.

2-Install it. With Vista install it in a directory like your documents or downloads. Then it will have full write permissions. It's a Java applet and works a little different that most windows programs.

3-Launch it. You will see the small Image J box. (For don't-want-rewrite-the-software reasons you can't resize it. On an old VGA screen it looked big.)


4-Click on edit-options-plot profile options. Out of the box, ImageJ autoscales. Since there are 256 gray levels (0 black to 255 white) set the minimum Y to 0 and the maximum Y to at least 255. I use a fixed scale if I'm making comparisons since it makes the differences more obvious.

If you are doing something else, set it any way you want. This box only effects how the plot will look. Click OK to set the scaling

5-Click on file and open an image.


6-Right Click on the line icon box (the fifth over). With version 1.42 you can now draw straight, freehand and segmented lines. Pick a type and drag a line in the image you opened.

7-Hit control+K or the MAC equivalent. Or go to analyse-plot profile in the menu bar. ImageJ will calculate and plot out the grey scale values under the line. If you drew it in an area where there is little detail except for noise you will have a noise profile.

8-Enjoy

Saturday, November 7, 2009

Fun with imageJ

This blog is a detour or more accurately a jump-ahead from what I'd planned. When I finished the last post I'd planned to talk more about noise theory, have my buddy bring over his cameras for the measurements, post what we discovered and finally talk about imageJ and lay out how anybody, including you, my dear readers, could do the same measurements with your camera(s).

But once my last post was out in the world and I couldn't find the Badger game on TV, I downloaded the latest and greatest version of ImageJ. Once I started to play around with it I discovered some neat things to share.

ImageJ is scientific image analyser. Scientists around the world use it to pull out the data buried in the their images. Then they write their research papers, give them at confrences and publish them in journals that only scientists can understand.

Buried in my images is data on how good the Lightroom noise reduction routine is. From it I can settle which lenses to use for the YSP dress rehersals photos. Then I'll pass the pictures around in person or by email before I publish a few in this blog or on flickr. Same workflow as a research project--just more informal.

Everybody has a research project. ImageJ can be your friend. It comes free from the NIH, the National Institute of Health. So Google and download it. It's fun to play with.

In the 'What is Noise' post I talked about pixels being like penny jars. And how you filled them with photoelectrons (the pennies). And how you could measure your camera noise once you took an image of uniformly illuminated white card.

All true. But I didn't have to do all that.

Using imageJ, I loaded the blowup of Laura's head with no noise reduction. Then I dragged the yellow line down a black area. (Click the image to see it large.) With a control-K, imageJ created a noise profile from the 600 plus pixels under the line and plotted the gray scale values for me.

Gray scale images have 256 tones--255 is pure white and 0 is jet black. From these values you can calculate back to learn the number of photoelectrons in a pixel. But for this experiment I didn't need to do the calculations.

Instead I did the identical thing with the blowup of Laura after noise reduction. One glance and you can see that the noise reduction routine works. Fairly well too.

The next step is to do more comparisons to see which noise reduction programs--I have several--work the best

Once again imageJ has added new features since the last time I downloaded it. I find the free hand line profile neat and useful. In the third image, I've measured the dark background, Laura's hair and her cheek. In the hair, the noise and hair texture is mixed together. Her cheek, however, is smooth but not evenly illuminated.

The noise from the cheek is riding on the downward slope of the graph and is circled in blue. In this jpeg image the cheek noise is a good deal less than the black backgound noise. Why is a subject for another post. It's more complicated than you might think.

What is noise?

What is noise? Thought you would never ask.

Here are a few facts about noise you won't find in a camera's hype sheet. Or on the review sites either. While things have gotten better--well regarded review sites like dpreview aren't pontificating absurdities about camera noise like they were a few years ago--but there is still much confusion.

All the facts I'm listing are out on the web somewhere-either in plain language or more often hiding in mathematical formulas. But I think it would be interesting to pull them together in one place. In more or less plain language,

Fact one.

Unlike film which works in a totally different way, digital cameras count photons. Photons are little hunks of light that work like bullets and knock photoelectrons out of the silicon that camera sensors are made out of and into the pixels that sit on the top of the silicon.

(Einstein won his Nobel Prize for working out how this works. He received the honor. His first wife collected the money. It was written in their divorce settlement.)

Fact two

Pixels work like penny banks. If you take a picture of a uniformly illuminated source--a white box by the window lit by a clear sky for instance--all the pixels will collect their photoelectrons, the pennies, during the exposure. Then if you add up all the photoelectrons and divide by the number of pixels in the camera you have your signal which tells you how bright it is outside. To make the math easy, today the signal is 1000 photoelectons. ("pe-" in engineering talk.)

If you empty a penny bank and count the number of pennies that are short or over 1000, that is the noise. For this example lets say you have 33 extra pe- in a pixel--a magic number I will explain in the next post.

Of all the ways to explain and quantify noise, the number of noise photoelctions is the easiest to work with. So we won't get into decibels, the noise numbers loved by electrical engineers. Today your noise is 33 pe- and your signal to noise (S/N) is 33. That's nothing to brag about but it's still a useable S\N

Fact three

The vast majority of the noise you counted is not from your camera. It from the light. I repeat. THE NOISE IS FROM THE LIGHT!

The noise is caused by the random emission of photons from anything that is hot enough to give off light--that means everything in our universe. Sun, flash lamp, candle, your big toe, puddle of liquid air, everything. The amount of light and spectra of the light will vary of course. With a medical tomographic camera your big toe becomes a bright source, but taking off your shoes won't help any if you are shooting a wedding. Still, regardless of where the light comes from, it carries its noise along with it.

What does this mean. Nothing a camera maker has done or ever will do can get rid of this noise--photon shot noise in engineering talk. Short of a trip to a sf alternate universe, the noise is not going to go away.

And if you noticed that I said "vast majority", what are the real numbers. By my calculations, if you own a Canon 5D up to 98 % of the noise comes from the light in a low ISO and bright exposure. And if you don't, with my carry-it-everywhere Oly SP350 up to 95% of the noise come from the light. Something I measured.

If you now think Old Scrib is sprouting total nonsense--his cheapo old tiny sensor SP350 doesn't take clean pictures like a Canon 5D--we'll explore the differences between noise and signal to noise in more detail in the next blog. If you want to understand what's going on inside your camera confusing the two terms can causes much confusion.

We will also get into how you can, with free software and not that much effort, measure how noisy or clean your camera is. A buddy of mine just bought a Canon 7D--their latest that's been on the market for only a few weeks. Next week he's bring over his older 5D and 7D and we will measure and compare them with my D60.

Be new info. Before the review sites post their noise figures. So keep watching the blog.

*edit* Not new info now--but first time bloggers have high hopes of scoping the big sites.

If you see this edit you are the fifth visitor ever, all today, to read this post. Put a comment in the comment box--so I know there is one-- and I'll think up a suitable prize.


To be continued: