Bits and Stretching
Up FITS Tutorial Intro Page MegaPixels and JPEGs Bits and Stretching

Bits is bits

One of the terms you’ll hear bandied about is “8-bit”, “16-bit” and “32-bit”. Yeah – so what’s with that? We’ll start is JPEG and move towards FITS. Hopefully you’ll see why FITS is a good fit for all of this. (pun alert – sorry)

In computer speak, there’s only one bit and that’s the bit that the computer is dealing with at any one particular moment in time. It’s either on or off. One or Zero. Yeah, we keep hearing this, but so what? Well, with one bit I get a possibility of 2 outcomes (1 or 0, on or off). If I combine two bits together, I get 4 possible outcomes (00, 01, 10, 11 – remember there’s only two values: 1 or 0. It’s not 10=Ten, it’s 10= 1 (on) and 0 (off)). If I combine 8 bits together, I get a total of 256 possibilities. Guess what – that’s significant because 8 bits is where JPEG lives. It gives you a very nice colored image that most any computer can display while being able to keep the file sizes small. Printed JPEG images can be very respectable.

JPEG deals with three colors – R/G/B (Red/Green/Blue). Each color has 256 possible shades. The intensity of the color is determined by the combined amount of these colors. White is R=255, G=255 and B=255. (Geek speak alert – technically Zero has value so it is combined into the range of possible values. 256 values means the lowest value is zero, the highest is 255, total is 256 possibilities. Capish?) Black is read as R=0, G=0, B=0. Pure red is R=255, G=0, B=0, and so on with different hues as combinations of each. The total amount of possible combinations is 255*255*255! Seems like life would be good and this would handle ANYTHING we can throw at it. Right?

Hmmmmm – what if there were more than 255 shades of each color, or levels of light? A healthy, young human eye can differentiate about 1100 levels of light (almost 1600 if you combine it with night vision). Film can detect about 800 levels of light. (Some modern film stock can detect even more.) And digital weighs in at a measly 255. And if I am dealing with something that has very faint changes in specific levels of light, I’m fairly restricted since these 256 levels range between pure black and pure white. The spaces between the values can represent quite a bit of information that can't be touched with just 256 levels.

If we had more bits we could detect more levels of light – even more levels than the eye can see or the computer can display! So if we upped the bit count to from 8 to 16, we’d be doing great, right? Not necessarily. FITS files use 32 bit image! That’s HUGE! But there’s a good reason.

Stretching

Remember that astronomical objects can be quite dim. Down right too faint for a naked human eye to detect. For astronomy, we take images where the camera is open for many seconds, minutes or even hours. We can even take multiple images taken over several days of the same object and stack the images one on top of the other and combine them all so that even some of the faintest details are available.

What if we can take some of that faint detail and “bring it out” so to speak? With 32 bit files there are literally thousands of levels of light between two adjacent levels in JPEG. And with the dim images, we can boost the intensity to a level that can be used by JPEG. In fact, we can pull quite a bit of detail out of the very dimmest parts of the picture so that we can easily see them. To do this, we need to stretch out the image – to bring out faint detail so that it is better seen.

This is the theory behind “Stretching”. If we try and bring out too much detail we can go overboard and “over-stretch” the file. (And this is a LOT easier to do if you’re not careful.) But we can boost very dim parts of a picture, preserve the detail we can see already, and not blow out the very brightest sections of the picture. We can literally take those very dim parts of a picture and stretch it out to see those beautiful dust lanes or edges of the arms in galaxies. We can see so many colors of a nebula. You can see the dim stars of a Globular Cluster. (Depending, of course, on the quality of the scope, quality of the camera, quality of atmospheric conditions, the moon, the sun, the scope mount, the drive motor, etc, etc, etc.)

So – 1) FITS file format has a lot more data available than other file formats. 2) To see some fine, faint detail, we need to stretch out this information to a more visible area.

Now – with all this theory and stuff, are you ready for FITS Liberator? I bet you are. But we need to cover one more thing.

BINNING

What exactly is binning? It is a way to increase the sharpness and brightness of an image by reducing it’s size. No kidding – it really works. Have you ever loaded an image into Photoshop and initially it looks great, only to zoom all the way in and see that it’s somewhat out of focus? Without knowing it, you’ve been binning. Binning takes adjacent pixels and combines them together. Soft edges will look somewhat sharper. Also dim objects may appear brighter. Fine – but how?

Here’s another brain twister. If you have a 4 megabyte image, and in Photoshop you reduce it’s size by 50%, what’s the final file size? (Insert Jeopardy theme here) If you’ve said 2 megabytes, you’re wrong. The size is actually a lot closer to 1 megabyte. The reason is that the image’s data is squared. See the following graphic to figure out why:

When you reduce the bits by 50% on the vertical then you also have to reduce it by 50% on the horizontal and the diagonal. If you don’t then the image will “squish” (technical term) on one side and not look very good at all.

If you see the term “Binning X 2” or "Binned by 2", then the image had been downsized by 75% (squared). Binning X 3 will reduce it to roughly 10%, combining 9 pixels into 1.

Why bin? By combining pixels, you can increase the brightness of an object by combining dimmer pixels together. It can also add sharpness and result in a more pleasing image in the end. And it’s also a way to reduce file size. Because FITS files have separate files for color and luminescent, and because the detail is in the luminescent file, you will typically see color files binned by 2 and the luminescent is unbinned. For our first example, we will use an unbinned luminescent file and color files that have been binned by 2.

BTW – reducing an image by 50% in PhotoShop is NOT exactly binning. Pixels may not get brighter, but the image will look sharper. I used this as an example, and we will also be dealing with binned files later on.

NOW are we ready to actually monkey with a FITS file? You bet. Let's move on to the video portion of the tutorial.