Sunday, May 15, 2011

(Digital) Camera vs. Eye

I am serious: the topic of this post is imaging, not physiology. This means I will not talk about how the eye camera works, but rather how the brain camera interprets images. Some physiology will nevertheless find its way through these lines, let us see how.
Let us begin with the easy thing: digital cameras. One main feature of all measurement devices is linearity, that is the ability to deliver a value directly proportional with the measured quantity (light, in our case).
If you think about it, that is a good thing: you can measure whatever value with a constant absolute precision. Do you want to use one inch precision to measure one foot in length? You have it! Do you want to measure the Earth-to-Moon distance with the same precision? There you go, but... what the sense in that? One inch is probably too much to measure with satisfactory precision one foot in length, and it is certainly nonsense for the Earth-to-Moon distance. I mean, what is the use of measuring 15 billion inches with one inch precision? And moreover, imagine you have a counter able to measure inches: one foot will be only 12" while Earth to Moon will be 15 billion inches, a number you can store in 34 bits. If able to perform such measurements, your counter would cover 11 orders of magnitude (from units to tenths of billions), not too bad!
But, what if you want to go and measure Sun distance? at almost 150 million km, that is 6'000 billion inches, a number you need 43 bits to represent, if you want to go with 1" precision. That is, covering 13 orders of magnitude.
Nature is wiser, it always was and will always be. When you see the Sun in its brightness, you are staring at something 20'000 billion times as bright as the faintest stars in a pitch-dark sky, a leap of 14 orders of magnitude to be covered with 45 bits. For a comparison, the precision of the raw format of DSLR cameras is 14 bits (from 0 to 16383 different levels); most pro CCD cameras use 16 bits (up to 65535), while only a few, very advanced cameras go up to 18 bits (up to 262'143).
How can eyes do better than our best technology, and in such a shameful (for the tech, of course) way? One reasonable reply is: “being reasonable”! First of all, we have already shown that a direct, linear correspondence between an input stimulus and the value we associate to it is not viable. As a first approximation, Nature uses logarithmic laws for this kind of things.
I know: logarithm is mathematics, and there are chances that you do hate mathematics, but there is no understanding without effort so, please, just follow my argument and I shall make my maths as simple as possible.

Logarithm function graph [source: Wikipedia]
Logarithm is a nice function, see it in the picture aside: it only grows (which is good for us, as we need higher sensations in reply to higher stimuli), it only exists for positive values (again, good for us, as there is nothing darker than no light at all, where we are going to fix our zero) and (now, for the hardest part) the rate of its growth decreases vs. the abscissa. The last property suits perfectly our needs, because it means that in reply to small stimuli in the dark (small x values) we get huge differences in the sensation, while big changes in high brightness (large x values) result in small sensation differences. You could say that this function tries to keep constant the relative precision of your sensations, i.e.: you perceive as different those stimuli that differ some given percent one from the other, independently of the stimulus you receive. Imagine that the value of this given percent is 10%, then you will see that a light stimulus of, say, 8, is different from 10, but 92 and 100 will be barely distinguishable, if ever.
Does this thing work? How well? In astronomy, for instance, light intensity of stars is given in magnitudes, and the difference between one magnitude and the next one is a constant, multiplicative factor of 2.512. Being multiplicative, two magnitudes in difference means 2.512 × 2.512 =2.5122. This means that light intensity can be measured by magnitudes with the inverse of a power law, i.e. a logarithm law. Is it that easy? Well, yes, and if it is good for astronomers, I assume it is good for me, and for you as well.
Actually, a more precise law is a power law, as those of you who already play with the gamma in their images know only too well, and magnitudes are nowadays measured with an hyperbolic sine law that handles some problems that may arise with logarithm in very dark images in a more robust way than logarithm does. Do not worry about that now, any difference with what I wrote up to now is inessential AND I will dedicate a post soon to both these topics (gamma and magnitudes) in a short time.
Is it enough? No other mistery than that? Well, sure there is, think about it: when you enter or get out of a tunnel while driving in a sunny day, chances are high that you will need some time in order to let your vision adapt to the new lighting conditions. What happens during this time?
This adaptation to the new light conditions allows you to see although with an ambient light 10'000 (that's it: ten thousand!) times as dim/bright as the previous conditions.
That is not an easy feat: the retina of your eyes is filled with rod and cone cells. The former are more sensitive to light and see in darkness, the latter are less sensitive BUT do distinguish colours. So, you do not actually cover the incredible luminosity range I wrote you about at any single time but, from time to time, your eyes adapt to the optimum sensitivity range. Don't ask me how eyes do that: they had millions of years to evolve to their perfection and I don't know any manufacturer wiser than Nature.

Why the eye is better than a camera at capturing contrast and faint detail simultaneously
[source: esciencenews.com]

So, is that all? Not yet. Up to now we have just seen how do our “detectors” (the eyes) work, but in human vision there is more that meets the eye (as the saying goes, and I find it quite appropriated to the discussion). The retina already adds something of its own by processing and manipulating the image in order to make it easier the task of analysing and understanding it. The main image processing technique operated by the eye is the edge enhancement, something you will find in your favourite picture processing software package, and able to make picture profiles sharper. In this way, the acknowledgement of shapes is easier, as they stand up over the image as the dark contour lines in a comic (so you know why kids draw so bold contours and comics are painted that way).
How does the filter works? As you can see in the image, retina cells on the bright side of a luminosity transition shut down their neighbours on the dark side, therefore making the transition look stronger.

EDIT (17/05/2011) - sorry for closing the post this way: it was late night and I completely forgot to write down a proper ending. Nonetheless, that's all, it's over. I hope you liked it and will comment about it.
See you for the next post,
Marino

Saturday, May 7, 2011

Camera Lenses: Technical Excellence

In my previous post I advised to make up an idea about what you actually need, before going and buy a camera. I also discussed the different sources of information needed to make up this opinion, warmly counselling the DPreview website.
A good camera (that is, DSLR) will allow you to capture a good image if provided with a lens fit for your application/subject of interest. For instance, I love astrophotography (more on this in next posts, I promise), which means I should be using wide lenses (in order to capture more light) and fast ones (in order to capture that light in a small time).
But I also like macro photography of flowers and small objects, so that I would need macro lenses too (that is, lenses able to focus objects at very short distances, say 25 cm or even less) in order to capture those tiny details.
And then there are different requirements for landscapes or portraits. In the former case, software programs allow stitching contiguous images of a given panorama together in order to build up a much bigger image in terms of pixels, thus allowing even small cameras to produce very nice results. On the other side, the camera optics should be as aberration-free as possible in order to allow better scene reconstruction. The only disadvantage of this technique is that something may move from one frame to the next one (waves at sea, for instance), thus rendering impossible the image stitching.
The other way is to buy a wide-angle lens (typically, less than 28 mm focal length on a 35 mm sensor) and capture the whole landscape in only one shot. The problem here is that you are resolution-limited by the camera you are using, and if you plan to make wide enlargements of the picture, pixellation of the image will show up.
As for portraits, very typical focal lengths (say, from 50 to 85 mm with a 35 mm sensor size) will come handy, as you want to reproduce a scene in a manner as similar to what your eyes see as possible. Part of this resemblance is also given by a concept defined by a Japanese word: the bokeh.
On Wikipedia (for those like me who do not dominate Japanese) bokeh is the blur, or the aesthetic quality of the blur, in out-of-focus areas of an image.
In other words, a good photographer is able to picture the subject and its surroundings, and make you see it as if you were there. But, as your eyes cannot focus at the same time objects near and far, a good photographer will also try to emulate this phenomenon by using a small depth of field with his camera, i.e. the subject of his picture will be razor-sharp but everything else will be nicely blurred.
In its turn, a small depth of field is obtained with wide lens aperture values (f values not bigger than 2.8). This means that a desirable requisite for a good lens dedicated to portraits is a wide aperture, which means money.
I could go on and on with examples, the bottom line is: know what you want it for, then you know what you want! More important is where to look for information that will allow you to compare among the huge amount of lenses in the market or discontinued.
A first advise may well be DPreview again: here you find the page for the lens reviews, with plenty of information and comparisons (just like we saw for cameras), but I want to introduce you to an even better website, for the kind of use we have in mind: photodo.
Why do I say that photodo is so better than dpreview? For one simple reason: MTF, Modulation Transfer Function. I beg your pardon if I try to use some “scientifically professional” concept on these pages, but the simple fact that I find it used on a website not scientifically committed makes me believe that amateurs too will take advantage applying it.
Here you find a definition for MTF. Let us see what it means.
Let us consider a comb with teeth with variable spacing. We can assume that the alternated pattern tooth-space-tooth can be seen as a sharp sequence 0-1-0 (or 1-0-1, doesn't matter). If we try to take a picture of this pattern with a camera, it will be converted to a sequence of blacks and whites, the steeper as the detector pixels are tinier (as they better represent the actual pattern) and the teeth are more spaced and opaque.
For any given spacing (spatial frequency) of the teeth, the MTF tells you how good your image represents the actual comb pattern, assuming any value between 0 and 1, with 0 meaning that the comb is actually rendered as a perfectly flat object and 1 meaning that the comb pattern is perfectly reproduced in shape and intensity.
At photodo they make this simple thing: they take pictures of a standard pattern representing various spatial frequencies through virtually any lens there is/was in the market, then they rate it on a scale of five depending on different parameters but, as I was saying before, MTF is one of these. They are so strict that no lens has earned yet the 5 stars rating but, on the other side, this means that any lens with a rating higher than 4 can be considered as very good, top class or excellent.
You will find any kind of lens, some with the MTF graph, so that you can compare form a pure mathematical point of view the quality of your lenses. Through this link, for instance, you have all of their lenses sorted in descending quality order. I hope you find it interesting and helpful.

Saturday, April 30, 2011

Looking for References in Choosing a Camera

A picture is the fruit of the combination of many elements: the right scene, under the right light, captured by a decent camera by a capable photographer... There is so much more than this, but let us assume we took into account the most important factors.
Now, the right scene can be prepared by the photographer in his studio, otherwise it is all a matter of chance. The same can be said about the lighting conditions (usually flashes will only give you more light, not better light). These factors are therefore out of our control, now let us see what we can control.
Let us assume we are capable photographers (laugh, please!), we are left with only one parameter to tune up in order to get proper pictures: a proper camera (actually, a proper camera with proper optics, but we shall discuss camera optics in another post). How do we choose a proper camera?
Our resources are mainly: knowledgeable friends, knowledgeable shop owners, Wikipedia and some specialized web-site.
Knowledgeable friends I have plenty. There is my father who was a life-long amateur photographer and proud possessor of Nikon manual cameras in the past and a Canon DSLR right now. Anyhow, he was not able to follow the tide of the change and is struggling to get results comparable with the ones he got in the past. There is my friend Matteo who simply bought a Sony DSLR and shoots like a mad man. His knowledgeable advise is to use a reflex, period. To him, whatever the brand, the camera must picture what you saw at shooting time and he is right: that is the job of a camera: if you do not get the picture you saw at shooting time, what is the purpose of the camera? Now, if the picture you saw and shoot is worse (much worse/unbearable) than you could ever imagine, we have another issue there, but we are assuming we are capable photographers here, remember? There is Otger boasting his camera (an “entry-level” Canon DSLR) is the best in the world, only to complain he cannot afford the upper model...
Shall I go on with this? You can get as many opinions as you look for, because at an amateur level there is actually no right camera for everyone. Manufacturers try to squeeze tons of technology and features inside a camera body, but in the end the camera and the photographer unite like in a marriage: they are made one for the other and vice-versa.
Want me to prove it? Go to a professional photographer, and ask him if he ever saw a colleague of his dropping the best camera on the market just because “the buttons are not where I expect/I am used them to be”. Such and more apparently absurd tales always existed and will always exist.
But this is not a bad thing, as it allows us to avoid the next big danger for an amateur: the knowledgeable shop owner. This guy will usually be a little more skilled than you and I (consider he can use whatever new camera comes in store), and is actually more interested in selling expensive stuff than in helping you with choosing the right camera for you. For one thing, he has the full right to behave so: as he already knows that there is no right camera for anyone, how could he devise the right camera for you? On the other side, more expensive stuff will also provide you with a little more reliability, which is never enough. The market is plagued with crappy stuff and, if you have little or no experience in handling photographic equipment, chances are high you will end up breaking your camera sooner than later.
Is buying branded stuff a good way to avoid unpleasant surprises? No. Google around and you will find plenty of complaints about this or that camera/lens/accessory from a famous brand that broke at the first fall, drop, hit, and it was dearly paid.
Here we come to a sensitive spot: how much does this kind of equipment cost? Surf the web, document yourself, and you will find whatever price from whatever brand. How can you discriminate the quality in this market? My advise is to treat every brand as a different case. Sony, for instance, will cost you less than Canon and Nikon, but all its models will be consistently cheaper than the corresponding ones from the latter two brands and, with the cost, quality is supposed to improve too. On the other side, cheap equipment from Canon or Nikon is not supposed to be good only because it is from this or that brand: if you want more quality, you have to spend more.
So, where are we left? Let us start from scratch: we do not know anything about photography and want to know what camera brands do exist on the market. Wikipedia is good at this. Here you find a very helpful table (at least for those who can read it). First, you see that the big producers are a handful of them, and now you know what the real alternatives are. Then, in this table you find some details that may (or may not) be of your interest, but they do influence the final price of a camera.
The problem with Wikipedia is that it will not go into the details that you want to know, unless you jump from link to link, from article to article, in order to understand every little bit of information written there. A more suitable place for this is a renowned and independent website offering reviews of all the cameras available in the market: DPReview. Go there and you will find all the information you want to know about any camera you may want to buy, with direct technical comparisons between different models from different brands but from the same market segment: that is exactly what you want to know!
Even if you are a niche user (that is my case, for instance, as I want to make astrophotography too), the reviews there explore into every little detail the cameras, therefore allowing you to build yourself a better consciousness of what you need/want to buy.
As a small example, let us compare some Canon cameras for the same customer segment: the Canon EOS 400D, 450D, 500D, 550D and 600D (I am from Europe: they are otherwise known as Digital Rebel XTi, XSi, T1i, T2i, T3i or Kiss X, X2, X3, X4 and X5). Let us go to the requirements I deem mandatory: for astrophotography I want high sensitivity with low noise, a “bulb” exposure mode and the ability to save the images in a lossless raw format with as many bits per pixel (bpp) as possible; for HDRI (High Dynamic Resolution Imaging) I want a wide exposure compensation bracketing. As you can see these are rather odd requirements, let us see if DPReview provides them.
On page 21 of the EOS 400D review we read that this camera does provide a lossless raw format, a sensitivity of 1600 ISO, a bulb mode, compensation of up to ±2.0 EV (bracketing is not mentioned). I keep totally out of the game the camera resolution or other things you will hear people boasting about, as I am not interested in them. This is a very important step: what kind of photography do you want to make? Then decide your camera based on these requirements.
On page 23 of EOS 450D review we find that this camera comes with a 14-bpp raw format, and basically the same features of its predecessor. But a comparison between the chroma noise curves (page 20 for the 450D review and page 18 for the 400D) shows that the even without enabling the noise reduction, the newer camera behaves at least as well as its predecessor, which is to be considered a major improvement, as to tinier pixels (over the same sensor size the newer camera sports 12.2 megapixels vs. 10 of its predecessor) should correspond higher noise levels. Considering that the former camera comes at the same price and packs some improved technology, the choice follows easily on this model.
The next model, the 500D, is certainly a major improvement from many points of view, but let us see if that is gold for our application: raw, 14-bpp fine, the sensitivity jumps up to 12800 ISO (!) but on page 15 we see that only the black noise (i.e., read-out noise) is comparable with its predecessor. There is no sense for our application to push further in sensitivity, as we see that with ISO's, noise too is dramatically increasing. But we already expected this to happen as the newer camera sports 15.1 megapixels over the same sensor format.
The next camera is a true show-stopper: with its 18 megapixels, EOS 550D features a chroma, black and grey noise (page 14) lower than 500D. This is a true advancement, as images taken at 3200 ISO feature the same or less noise than a 450D at 1600! As for the exposure compensation, it now ranges ±5.0 EV (but still, this is not the automatic bracketing): this camera is a small wonder.
Shall it be surpassed by its latest sibling? If we take a look at the graphs on page 10 of the EOS 600D review, we immediately see that the black noise at very high ISO (> 1600 ISO) for this camera is higher than for its predecessor, while at lower sensitivity values it keeps unchanged. Observing the other main features, we discover that nothing has really changed that would make us prefer this camera over its predecessor, and considering that newer models always do cost more, our choice would go, obviously, to the 550D: our choice is done!
Why did I choose Canon cameras instead of Nikon? My personal taste would be for Nikon, but only very recently Nikon introduced a truly raw format. You can read here a direct comparison between the two (in French) and about the infamous Nikon noise suppression “mode 3”.
What about me? I am a proud possessor of a 450D, but I bought it when 550D was not on the market yet, and we have already seen that 500D would have not fit my needs.