Tuesday, July 17, 2012

Image Stretch and the Effects Thereof

Today I just want to briefly discuss a very important decision that went into making the transit of Venus video I posted last time. That decision was how to stretch the images from the CCD camera. You see, the CCD camera has a wide range of sensitivity, with 65,536 different light levels it can record. Most monitors cannot display anywhere near this amount of contrast, so the image has to have that range compressed down into what the monitor can display. In theory, this means that a lot of detail is going to be lost, and that's where stretching comes into play.

Stretching an image's histogram basically means reassigning how the compression takes place. When you're looking at an astrophoto, you may have 65,536 different levels of brightness, but a large number of those are probably going to be so close to black as no matter. You can then adjust the stretch so that they simply display as black, leaving more of the dynamic range of the monitor available for seeing detail in the brighter regions. Essentially, the image stretch lets you decide which regions of the image you want to see detail in based on their brightness.

To illustrate how important the stretch is, let me give you some examples. Immediately upon applying the reduction process to one of the images of the transit and importing it into GIMP, we get this picture:


To the left you can see the Sun with Venus in front of it and a few sunspots visible near the middle of the disk. On the right you can see the default linear stretch currently applied to the image. Basically, it maps a zero value in the image to black, a value of 65,535 to white, and linearly compresses everything in between. The horizontal scale is the brightness levels of the original image, the vertical scale is the brightness levels on the monitor, and the gray lines are a histogram representing how many pixels there are at each brightness level. What it tells us is that this image has a lot of very dark pixels (on the left, all the background), a lot of very bright pixels (on the right, the center of the Sun's disk) and a moderate number in between (around the edge of the Sun, and things like sunspots).

Speaking of sunspots, I quickly discovered that there were more than could be seen with just the default linear stretch. By cutting off the left end of the histogram pretty dramatically with another linear stretch, I could bring out details as yet unseen:


In some ways, this worked quite well – sunspots had much better definition, and you could see more of them. The main problem to me was that it made the outside edge of the Sun look a bit grainy. I ultimately decided that it was not quite good enough, and continued looking for a suitable stretch. My next attempt, which I'm calling an “exponential” stretch, looked like this:


This stretch is similar to the previous linear stretch, but leaves more detail in the dark areas. Again, the sunspots looked good, but it looked even worse around the edges than before. After playing around with variations on both of these (plus several others), I finally came up with the curve that I would end up using:


This curve is, ultimately, a compromise. It doesn't show the sunspots quite as well as either of the previous curves, but it looks much better along the edges (at least it does at 100% magnification, they all look about the same in these pictures). It took me quite a while to decide on this curve, because I'd keep looking at it and tweaking it and trying to get the absolute best curve possible, especially since I was going to be applying it to the next one hundred and eighty-seven images and didn't want to have to go back and redo it. It wasn't a decision lightly made, I'll say that much.

I also see that, having sat down to write a “brief” blog post, I managed to write a 650-word essay. I don't know why that always seems to happen. I hope you at least found it interesting. I've come to appreciate the image stretch more and more as I (hopefully) get better as an astrophotographer, and it should show in some of my upcoming pictures. A hui hou!

1 comment:

Think I said something interesting or insightful? Let me know what you thought! Or even just drop in and say "hi" once in a while - I always enjoy reading comments.