20081115

RegiStax vs AviStack

A comparison between stacking in RegiStax (Left side) and AVI Stack (Right side). Click image to see the full resolution image.

A comparison between stacking in RegiStax (Left side) and AviStack (Right side).

I was recently introduced to a new and free (as in beer) stacking program and have been testing it. The program is called AviStack and it is written in a language called IDL. I’ve been programming in IDL since 1981 and have considered writing an image stacking/processing application with it for some time. Someone has beaten my to the punch and done a very good job in the process. One particular thing of interest is that there are free IDL virtual machines for most operating systems and so AviStack will run on just about anything. So the question is: Is it better than what is out there already?

We’ll see in a moment, but first, What is Stacking? Stacking is pretty much what it sounds like. Multiple images of the same thing are aligned and averaged together to improve the result. Averaging multiple images allows you to increase the signal-to-noise ratio of the image and overcome geometric distortions due to atmospheric turbulence (aka Seeing). See this post for a glimpse at the magic of stacking. The stacking process is comprised of a number of algorithms. The individual frames of the AVI have to be graded for quality and then aligned with a master image. When imaging a large object such as the Moon, the stacking process is done on several pieces of the image separately and then combined into the full frame. The reason for this is that atmospheric turbulence causes regions of the images to move relative to one another as well as warp and blur. Therefore, the stacking program has to look at every frame of the AVI and decide what, if any, parts of it are usable. Since the part of the image the program wants to use is probably warped/distorted geometrically, the alignment algorithm is another important task that has to be done well. Finally, the program has to keep track of what part goes where during the stacking/averaging process.

The image above is a side by side comparison of images produced by the “Industry Standard” - RegiStax (Left) and the new comer - AviStack (Right). Click the (or any) image to get the full resolution image to get the full impact of the comparison.

RegiStax has been around for a long time and is probably the single reason why amateur astronomy has made huge strides in the last several years. It is also free (as in beer) and is under active development. It works on just about any type of object and has a lot of controls to learn. The manual is borderline useful (being a translation to my native language) and so learning what each control does is more or less trial and error. Nevertheless, it is easy to learn. One of the most powerful aspects of RegiStax is its post-processing capabilities. It has a sophisticated sharpening tool based on Wavelets that is simply a must have for me. This comparison is based on RegiStax version 4.0.1.1.

In my comparison, the RegiStax result (Left side) was produced using the Human grading algorithm and 20 alignment points. The stack is the best 200 out of 1300 frames. The image was sharpened with Wavelets in RegiStax and a modest Adaptive Richardson-Lucy Deconvolution (RLD) in ImagesPlus. I applied a Gamma correction of 1.30 in PhotoShop.

The AviStack result (Right side) used a 32 pixel grading grid and had about 1700 alignment points. The TIFF output file was converted to RGB in PhotoShop so that RegiStax would read the file for subsequent wavelet sharpening. As with the other image, a mild 5-iteration RLD with a 3×3 Gaussian PSF was applied in ImagesPlus and the gamma adjusted in PhotoShop.

As you have probably already concluded for yourself, the AviStack result is clearly superior. The overall resolution increase is striking. Let’s dig into the details of the good, bad, and ugly and try to uncover what is behind the differences. To do so, I’d like to discuss the differences between the way each program approaches the problem. The steps I’ll consider are ‘Setup’, ‘Grading’, ‘Alignment’, ‘Stacking’, and ‘Post-Processing’.

Setup:

RegiStax Setup Screen

RegiStax Setup screen

RegiStax requires that you select features in the image you wish to use for grading and alignment by placing square regions of various sizes manually with the mouse on a single frame from the AVI. You need to be careful placing alignment points near the edge of the frame since in most cases the image drifts during the length of the AVI. Having an alignment point drift out of the frame is a bad thing in RegiStax. In my test case I placed 20 alignment points/squares (128×128) and then saved my settings. RegiStax does have an automatic mode to place alignment points, but I have never really gotten satisfactory results with that and always place my points manually. The maximum number of alignment points in RegiStax is 99.

AVI Stack setup screen

AviStack Setup screen

AviStack first needs to determine the drift in the image over the course of the AVI. To do this the user selects two features in a frame and places small squares on them with the mouse. The program then runs through each frame of the AVI to calculate the direction and rate of image drift. AviStack also estimates the amount of distortion due to seeing. When completed the user then sets a few controls that will determine how the alignment points are placed. There are two controls that identify regions that are too dark (space is dark after all) or too bright (overexposed) where there is no need to try to recover information by doing an alignment.

AVI Stack Reference Points

AviStack Reference Points screen

Once the controls are set, a press of a button will generate many alignment points automatically. The program generated 1688 alignment points for my test case. Points can be added or removed manually if needed.

Pros and Cons: AviStack is certainly easier to setup primarily because the automatic alignment point selection works well. I don’t have to worry about image drift with AviStack either. Both have the ability to save the point placement information for easier reprocessing. I’ll give AviStack a slight advantage in the Setup category.

Grading:

RegiStax Grading

RegiStax Grading screen

Having performed the Setup, hitting RegiStax’s Align button performs an initial alignment and quality estimation or Grading of the areas around each alignment point (within the specified box). RegiStax reads the AVI file multiple times, once for each alignment point. Using FFT-based algorithms to calculate rough integral pixel alignment and image quality, it chugs through all of the alignment points. This process is not fast, but it does allow the user to monitor the process and correct problems. The problems encountered most often are an alignment box drifting off of the edge of the frame and losing the ‘lock’ on a feature. The former is not a frequent problem if you place your alignment boxes carefully to begin with, but the latter is a problem I frequently encounter. This initial alignment and grading step is not a fast process.

AVI Stack Grading

AviStack Grading screen

The approach to grading taken by AviStack is very different. The user selects a grid size and the program divides each frame into blocks of that size. The AVI is read once and a quality grade is calculated for each box. During this step the user also selects how ‘Deep’ the final stack will be (i.e., how many frames to stack). This process is as fast as it is for RegiStax to grade one alignment point.

Pros and Cons: RegiStax is very flexible in how the image is graded. I have found that different grading methods work best depending upon the type of object (Moon vs a planet like Saturn) or the seeing conditions (poor vs good). AviStack is very fast at this step of the process, but you have to decide how deep your stack is up front and regrade the AVI if you decide to change your mind. This is not a problem since you do not have to go back to the very beginning (as with RegiStax). In RegiStax, the stack depth is set after grading so the user can look at the frames going into the stack before choosing the depth. The Grading step is a toss up between the two as a winner will be determined by whether the user values flexibility vs speed.

Alignment:

RegiStax Alignment

RegiStax Alignment screen

After the frames have been graded, the RegiStax user needs to decide on the depth of the final stack by setting a slider to the last frame (for the first alignment point) and hitting the Limit button. At that point two new tabs become active and I usually create a reference frame. This is an important step in the process as the reference frame is used for final alignment. The reference frame is created by quickly stacking some small number (like 50) of the best images (based on the first alignment point). This is a single point alignment. Stacking based on a single point alignment averages out the warping due to seeing, but does not produce the optimal image quality over the whole image. I almost always set my first alignment point to be a prominent feature in the middle of the frame. The user is allowed to slightly sharpen the reference frame with wavelets. Once again many options are available during the alignment step. Once set, alignment commences with a press of the Optimize button. Then you can go off and read a book, get something to drink, something else to kill some time while RegiStax reads the AVI several times (again) once for each alignment point. Alignment is done to sub-pixel precision by calculating the position of the maximum of the local correlation matrix. Again things can go wrong here as it is possible to lose lock on an alignment feature. RegiStax does have a few options to predict the track of features as the images drifts over the duration of the AVI, but it is not apparent that this prediction is remembered from alignment point to point. It could be used to help maintain lock.

AVI Stack Alignment screen

AviStack Alignment screen

AviStack reads the AVI file once during the alignment step. For each frame, it uses the quality estimates for each quality grid box to determine which, if any, alignment points fall in a box that is good enough to be used in the stack. Those that do are aligned with respect to the feature found in a reference frame which is simply the average of all frames in the AVI. As the alignment is proceeding, the user sees the location of the original alignment points along with the location of the feature (both indicated by colored crosses on the image). Under all but the worst seeing conditions, the pattern of deviations should be reasonably smooth (correlated within a small area). Random fluctuations in the pattern of deviations indicates a problem which is correctable and reasonably well addressed in the manual. AviStack can track very low contrast features exceedingly well. As a result it can extract features in regions that you would otherwise think are featureless.

Pros and Cons: AviStack is a bit faster at this step in the process as well. It is also a very robust process. RegiStax is more likely to lose lock on a feature (although occurrences are not very common). In the lower left corner of the test comparison image at the top of this article you will notice that RegiStax had a problem locking onto the craters in the darker regions which resulted in faint displaced doubles. If you change your mind on the stack depth in RegiStax (or anywhere else in the work flow) you pretty much have to go back to the beginning. In some cases you should probably exit the program and restart it. The manual clearly states that canceling an operation can leave the program in an unpredictable state and that has certainly been my experience. The winner in the Alignment stage is clearly AviStack due to its speed and accuracy. Once again RegiStax does offer more flexibility, but I personally rarely use it.

Stacking:

RegiStax Stacking screen

RegiStax Stacking screen

RegiStax uses the location of the alignment points to divide the whole image area into polygonal regions with one alignment point inside each region. Using the best frames determined for each region it then interpolates the image (yes this means a potential loss of resolution for undersampled images) to the destination grid at each point in the region’s polygon and averages the frames together. Again in the usual RegiStax way there are many options to control and tailor this process to the user’s needs. One that is particularly useful is the degree to which adjacent regions are feathered to blend across polygon boundaries. The polygons can be significantly larger than the alignment box and so the quality of the region of the frames outside the box can be poor. At least with the real world seeing that I have where I live, there is significant smearing during stacking due to image warping within the large polygons.

AVI Stack Stacking screen

AviStack Stacking screen

Here is where all of those alignment points ultimately pay off. Like RegiStax, AviStack stacks the interpolated sub-frame data into little polygon regions with a single alignment point in each one. The polygons are so small, however, that the blurring due to warpage from seeing is minimal. The result is that very fine detail is preserved and enhanced by uniformly accurate alignment.

Pros and Cons: Simply because of the sheer number of alignment points and the corresponding smallness of the polygonal sub-regions, AviStack will produce a more uniformly resolved result with a higher average resolution than you get from RegiStax. There is no aspect of RegiStax’s performance or flexibility that can outweigh this. AviStack wins hands down.

Post-Processing:

RegiStax Wavelet tool

RegiStax Wavelet tool

You will need RegiStax simply because of its Post-Processing tools. The Wavelet sharpening process has to be seen to be believed. It is very powerful and a little goes a long way. It is very easy to over sharpen and produce an unrealistic image. This is very much a learn by doing process and it took me over a year to get it to do what I want. It was time very well spent.

AviStack has no Post Processing capabilities. The TIFF format you can save the image to is not compatible with RegiStax, at least for gray-scale, monochrome images. I usually convert it to RGB in PhotoShop before going to RegiStax for the Wavelets.

Pros and Cons: RegiStax wins by default and would put up an excellent fight had AviStack offered any tools.

Closing thoughts:
You will have to have both programs. AviStack is a fabulous new stacking program that produces astounding results and at breakneck speed. Although I have not covered it here, AviStack does not work for me with planetary images (at least on my system where I’m not using a V7.0 IDLVM, but rather IDLDE V6.3). The author assures me that it does indeed work, so I must be doing something wrong. I’ll update this once I get it working. RegiStax has a wavelet sharpening tool that you simply must use. RegiStax V5 is due out in the near future and I will certainly try that out as soon as I can and revisit this comparison. I have reprocessed and compared a lot of images with RegiStax and AviStack. A few of them from nights of excellent seeing and of detailed terrain produced close if not indistinguishable images. I have not seen a case where RegiStax produced a better image, at best it was just as good, but often AviStack’s result was superior (especially when it came to the uniformity of quality).

The current trend among the top tier lunar imagers is to stack only a few images. They will stack only the best 20 out of thousands to make sure they get the best of the best. I think AviStack is going to change that - a lot. Because of the very small regions it uses for alignment and stacking, users of AviStack can and will stack more frames. There is no penalty for doing so.

AviStack has a bright future. I would like to see the author publish an API and provide hooks where 3rd party IDL gurus like myself can add tools to the program. I’d like to add a mosaic tool, for example, and I’m sure someone would generate a host of post-processing tools like Wavelets or RLD or …

Both programs have features and short-comings that I have not covered that others will deem essential or show-stopping. I do encourage you to give both of these programs a try and let me know what you think.

20081107

GM near death

I understand the argument that saving GM with a $25B “loan” might prevent an $80B shock to the economy, but who can say whether $25B will save them? GM does not produce a quality product that the consumer wants. If they did they would not be in trouble now would they? Then there is the other problem of the high cost of union labor. I’m sorry but I do not believe that a guy/gal with just a high school degree and a union job should be earning $100K+/yr putting parts of a car together.

If GM can come forth with plans/agreements that cut the cost of labor in half, build cars of the future (i.e., don’t rely solely on giant internal combustion engines), and do so with a quality product - I’d be in favor of a loan. Otherwise let them die and well pick up the pieces later. I still think they should be building wind turbines instead of cars.

20081104

Election Prediction

2008 Sticker

2008 Sticker

I’ve cast my vote for president and was pleasantly surprised that I had virtually no wait to do so. I’ve been playing with some on-line electoral simulators recently and predict that the winner will end up with 338 electoral votes. The shocking news came this morning when I read and realized that Karl Rove chose exactly the same state-by-state outcome that I did. Very scary.

If you have not done so already - Go VOTE.

20081016

New Flickr layout

Flickr just changed the layout of every users home page. Some of the changes are good and some are good or bad depending upon what you like. One change that bothers me, personally, is what they have done with what used to be the “Everyone’s Photos” setion. It is now a more general Explore section with randomly rotating topics - one of which is the old “everyone’s photos” I’ve grown to love. I would like to have the option of what appears in the Explore section. While some may like the rotating feature, I personally just like to have “everyone’s photos” be there - always. Other users have expressed the decision to mix the comments we have made on the photos of others with the comment others have made on our photos. The old way kept them separate - which again, I liked.

Web 2.0 is all about the user & their experience. What this means is that we should get to choose what things look like. Flickr, don’t impose changes on us, just give us more choices. We like choice. Choice is good.

Eyeball Astronomy

It is a pretty rare event when I go out to the observatory and just look through the eyepiece. My eyes are not what they used to be and even if they were, there is just no comparison with the sensitivity of digital imagery. Tonight we had some out of town guests over for dinner. Afterwards, the guys went out to the dome for a quick tour of the sky. It was a beautiful calm night with a full Moon, but excellent seeing. I had the C-11 on the mount and we had a quick look at the Moon. It was way too bright even at 350x. So I moved over to Jupiter. WOW! The bands and belts had easily observable structure and strong color. Io was just about to go behind the planet. It was a nice crisp disk with excellent orange color. We moved over to the globular cluster M13 and enjoyed the mass of resolved stars. M57 - check, M27 - check. Then I wanted to have a look at Uranus. The pointing was a bit off as was the focus. I tuned the focus on a star and was greeted by a nice Airy Disk and complete and stable first diffraction ring. Found Uranus - it was a crisp disk with a lovely blue-green color. Obviously not a star. Neptune was also a clear disk, although considerably smaller. Color was not strong. I think my guests were just as blown away as I was.  I thought long and hard about switching over to the digital imaging gear, but I fought that urge and will happily live with the memory of sharing an exceptional night with friends.

20081008

Debate #2

Voter: “Senator McCain, How would you … ?”

McCain: “My friend, I know how to get things done.” Followed by attacks.

And so it went for 90 minutes. I thought the town hall format was supposed to be his best event! At this stage I need to know specifics. Ideas. Why I am going to vote for you, not why I have to vote against the other guy. At least I can take some comfort in the fact that there is now less than 4 weeks until this turkey is done.

‘nough said.

20080929

Bailout: Round 1

I’ve got so many thoughts and emotions running around my head that I will have to take some time to sort out things rationally. However, my irrational response is as follows. I find it somewhat befuddling/amusing that it is the republicans that are against the Wall Street bail out! Aren’t the Republicans the ones who are supposed to be in favor of big business and against the average Joe? Did they want more? We’re they repelled by the cut lines to the golden parachutes for CEOs? And conversely, why are the Democrats so gung-ho in support of this? Is it because of the help for those who borrowed under ‘unsavory terms’ for their mortgage from predatory lenders? I don’t know, but it isn’t making sense to me right now.

I must admit that if I was a republican in the house and had just sat through yet another partisan tirade from speaker Pelosi, I’d probably vote against it too. Of all of the people (and I use that term loosely) in the house, ol’ Nancy scares me the most. Today she had a golden opportunity to demonstrate a non-partisan side of her persona and she completely failed the test. If and when this bill comes back up for a vote, I would only vote for it if Nancy agreed to step down as speaker afterwards.

The thought of Obama and Nancy running things together was worrisome. Now it is frightening. It might actually be sufficient grounds for me to reconsider McCain. I’ll wait to see how Palin comes across in the VP debate before I change colors.

Good god it would be great to have a real choice beyond these two non-starters.

20080926

How did we get into this mess?

Here is another article that caught my imagination. As I read this I could not believe what I was reading. Why do people have to be told these things? We have been saving for retirement for quite some time. We keep our cars for at least 10 years. We did not build the biggest house we could have qualified for (although it will be paid for in 2 years). We do not have to have everything - every new gadget, fashion, or trendy experience to be happy. We do not have to give the appearance of affluence to be affluent (whatever that really means). At the same time we do not deny ourselves very much. Perhaps I would define this as being realistic and living realistically. Setting proper expectations is the key to happiness. I’m sorry but the problems we currently face with the mortgage meltdown and financial collapse is primarily a manifestation of having unrealistic expectations. We have taken a huge and hopefully short lived hit to our savings as a result of the excessive lifestyles, unrealistic expectations, and outright greed of others, but I know we will be alright. I can’t say the same for everyone else because I think they believe they deserve more than they will ultimately obtain from the future. There is a bigger collapse looming than the current market crisis, it is a return to reality from this fantasy many of our neighbors are living. As I drive to work each morning I often wonder how these neighbors of mine afford to keep up the appearance that they strive to uphold. Now that the housing bubble has burst somewhat (I say somewhat since the valuations here have not changed much, only the growth has slowed a bit) we have an opportunity to examine our role in this calamity. I suspect few will take the opportunity to do so but rather bemoan that they are being denied their rights.

Teaching skills not facts

I was sent this link by a coworker as it sort of applies to one aspect of what I’m working on in my current detail assignment. It paints a rather bleak picture of the capabilities of our youth (which for me is anyone under the age of 35) and our education system. With this ‘No child left behind’ unfunded mandate (or should it be ‘all children left behind’?) we have established a system where the metrics require that we teach our kids what to think instead of how to think. We teach to the test now. When I got my Ph.D. I realized that it only meant that I was self motivated and knew how to think - nothing more, but also nothing less. Please view the video the link above points to. Realizing there is a problem is the first step in solving it.

20080907

Tropical Storm Hanna

Weather Data

Weather Data (click to enlarge)

Tropical Storm Hanna passed closely by yesterday afternoon. Aside from some tree damage and a broken mail box post, the storm was not much to talk about. This image presents some of the data from my weather station. The top graph shows the Humidity in percent (the red and green lines are the temperature and dew point - not to scale). The highest wind gust was 35 MPH. The third panel shows the temperature (red) and heat index (orange). The bottom panel shows the barometric pressure in mb (gray) and the rain (cyan). Hanna produced 0.85 inches of rain total.

« Previous entries