Archive for December, 2008

Wavelets for AviStack

Wednesday, December 31st, 2008
Wavelet Processing Screen

Wavelet Processing Screen

As promised, I coded up an add-on to AviStack that performs wavelet based image enhancement. The functionality is similar to the Wavelets found in RegiStax, but are subtely different as you’ll see in a moment. But before I tell you more about the new capability coming to AviStack, I’d like to thank Michael Theusner, author of AviStack, for giving me the opportunity to contribute, and Cor Berrevoets, author of RegiStax, for discussing the Wavelet implementation in RegiStax with me. This wavelet processing capability should appear in V1.74 of AviStack.

There are a lot of different ways to define and work with wavelets. Wavelets are most commonly used in image compression. For the image enhancement process, we use something called a stationary wavelet transform. Basically, this is a special case of the wavelet transform where the image is not decimated between levels in the filter bank. A filter bank is a way of describing how an image is decomposed through the application of smoothing functions called kernels. The original image is smoothed by convolution with a kernel and the difference between the original and smoothed version is called a layer 1. The smoothed version is then convolved with another broader kernel. The difference between those two are called layer 2. This iterative process is repeated for every kernel/layer in the filter bank.

For image enhancement, the kernels are selected to capture or represent detail in the image at certain resolution scales. This module uses a Gaussian kernel and the resolution scale is represented by the Sigma value (sigma * 2.35 = FWHM for a Gaussian). Each layer has a Sigma as well as an Amplitude. Normally, if you take the last smoothed image from the filter bank and add in all of the layers you get the original image. If instead, you multiply a layer by a factor other than 1, you can enhance or suppress the detail associated with that layer. The Amplitude value in each filter/layer is just the multiplicative factor (well almost as you’ll see). At least that is the way it works in RegiStax. In my version for AviStack, I decided to streamline the code significantly, by adding the Layer times the Amplitude to the original image. So with AviStack, setting all of the amplitudes to zero gives the original image. It is a subtle but important difference that you’ll need to remember if you are a regular RegiStax user. Based on a quick survey of RegiStax users, I decided to only implement a Gaussian kernel. I could not find anyone who uses the default. One thing that worried me while enhancing images in RegiStax was that I could easily blow out the highlights. So for AviStack, I added a Show Clipping button which shows the user which pixels will be clipped to white if the image is saved as a 16-bit format. Lastly, I added a control to adjust the image gamma. I think you will find that this wavelet processing is very fast compared to RegiStax, so the results of any changes you make are immediately displayed. I’m not sure whether most RegiStax users fully understood the implications of the Initial and Step controls, so I did not implement them. The user is expected to select the appropriate Sigma value – which in almost all cases should increase with successive layers (see figure as an example). Let’s get on with an introduction on how to use wavelets in AviStack.

There are six sets of controls for the six wavelet levels. Each set is comprised of a Sigma and Amplitude control. The Sigma control sets the width of the Gaussian for that wavelet. The current valid range of Sigma is from 0.16 to 2.00. The Amplitude control determines how strongly the wavelet is applied to the image. Its range is from -20 to 200. Clicking on any slider or Clicking & Dragging the slider bar will allow you to change the value. For single step adjustment (0.01), arrows are provided at each end. Results are displayed for the entire image immediately (or after the button release of a Drag). Near the edge of the image, data required for the wavelet does not exist. Rather than create data, the wavelet is not applied and instead the image is cropped. The number of pixels cropped from each side can be estimated by the following formula (#pixels = Integer( (largest sigma) / 0.16666)). So, if the largest sigma is 0.3 then 1 pixels will be cropped from each side. Two will be cropped if the largest sigma is 0.34 – and so on.

Pressing and holding the Show Clipping button below the wavelet controls will show where the processed image goes beyond the 16-bit range of TIFF or PNG files. Bright pixels with values beyond 65535 display as black while this button is held down. It is useful for monitoring the effect of wavelet processing on the detail in the brightest areas of the image.

There is a control to adjust the gamma. Again, results are displayed immediately.

There are a set of save buttons for FIT, 16-bit TIFF and 16-bit PNG files. Selecting one of these will bring up the usual save dialog. The file name defaults to the name of the original file with ‘_wvs’ appended followed by the appropriate suffix for the file type.

Finally, the two remaining buttons complete wavelet processing and return the use to the main AviStack screen. These currently do exactly the same thing – exit the wavelet screen, but will behave differently in a future version of AviStack.

Differences from RegiStax:
While these controls should be familiar to a RegiStax user, there are differences. The Sigma value is roughly equivalent to the RegiStax value times 2. Unlike RegiStax, the Sigma should get larger with successive layers since there is no other scaling being applied to the width. The Amplitude setting is a multiplicative factor applied to the wavelet. Unlike RegiStax where an amplitude of 1 represents no change, the enhancement of wavelet layers in AviStack are effectively turned off of by setting the amplitude to 0. Any zero amplitude layer followed by a non-zero amplitude layer is still calculated and impacts subsequent wavelet layers. Only those wavelets that are needed are applied. For example, If the third wavelet is the last non-zero amplitude layer, then only 3 layers of wavelets are used (as seen in the figure). Negative amplitude combined with larger sigma in the last layer used has the effect of reducing the degree of clipping in the brightest areas of the image.

Caroline Kennedy

Tuesday, December 30th, 2008

Well as long as I’m taking shots here today. Caroline Kennedy is, “ya know”, not exactly qualified for the Senate – by any stretch of the imagination. Simply being a Kennedy is insufficient qualification. She’s been, for all practical purposes, in hiding for decades and now pops up (with someone) wanting to make certain that there is a Kennedy in the Senate. There must be several other truly qualified and established public servants in NY that should be higher on any one’s list of potential appointees. Is this simply an ongoing media love affair with the Kennedy name or something more behind the scenes?

Oh (now for a cheap shot), and what is with that nose/spoiler/winglet thing she has going on? Has she been trying out for a part as an alien in Star Trek (Worf’s long lost half sister or something)? It certainly, “ya know”, looked better on her mother. If she makes it to the Senate at least the cartoonists will have a bizarre facial feature to grotesquely caricaturize.

Middle East Peace

Tuesday, December 30th, 2008

I’m going to cross a few lines here. If you disagree, please feel free to comment. I’m open minded and can be persuaded to change my point of view. Having said that, here I go.

First some context, I think it was arrogant and short-sighted when Israel was created after WWII. The local population did not see the Empire as having the authority to redraw the map and give away their land. I believe this act is the root of the current hostility. I can imagine other things contributing, but this is certainly the main problem. If this is true, then there can only be two long lasting solutions to the problem.

There have been so many attempts to solve the Middle East problem that there isn’t enough room or time to summarize them in a meaningful way. Let me just say that there has been a lot of give and take, but there has never been an agreement where every one of the parties that needed to partake could fully support. There are now so many factions in the area that is it is virtually impossible to get complete agreement.

These agreements and cease fires are tenuous at best partly because of the eye-for-an-eye Israeli way of neighborly foreign relations. All it seems to take is for a small group of neredowells to lob a few rockets over the border and we are where we are today – AGAIN. Honestly, I really can’t blame them. I have a hard enough time keeping my neighbors from driving on my lawn as they back out of their driveways. It is a good thing I do not own nukes, but I digress. The Israelis are not without blame. They do have a tendency to overuse bulldozers and erect settlements in sensitive areas with a thumbing-their-nose attitude.

I do not have a solution to the problem. I’m not that smart. Well I do have a solution, but it is a certainly too heavy handed. There are surely too many weapons in the area and they are in the hands of too many autonomous factions whose power is derived from sustained hostilities. If the neighboring governments had any control and authority over their countries and populace, there might be a ray of hope for peace in the region. As it is now, it reminds me of our Wild West days. I would not be surprised if things get very very heavy handed in the coming weeks.

I have a hard time decoding the oft quoted ‘we have a Special Relationship with Israel’ concept. I do believe that we have a fundamental responsibility for creating the problem in the first place. Honestly, if all of this was happening in the middle of Africa, like so many other and more horrible things are occurring today, we really would not care so much (not that we should not care). If it were not for the potential disruption of the flow of oil from the region and it, therefore, became just a moral issue as opposed to an economic issue, I do not think we would have a ‘Special Relationship’.

So other than making me feel a little better, where does this leave things? Although we would like to think of ourselves and the world as civilized, we are far far from it. We are too obsessed with Our Needs, Our Desires, and imposing Our Way on everyone else. We appear incapable of caring about anyone else, especially if they are not just like us. Civilized – yeah right!

Merry Christmas!

Wednesday, December 24th, 2008

Another year has just about passed and it is always a good time to look back and reflect. A lot has happened this year, some good and some bad. For us it has been good enough in that we are all still here and in reasonably good health and spirits. We hope the same is true for you and wishing that the next year will be better than the last.

Merry Christmas and Happy New Year!

Deflation Threat?

Wednesday, December 17th, 2008

I was just reading this story on CNN and began thinking (always something to be worried about). In the old days, deflation was a worry because the reduction in prices meant cut backs in production which led to job losses and salary decreases which then reinforced the deflationary cycle. Those were the old days. Now we hardly produce anything here – in the US – anymore. The production is overseas. Yes we still have sales jobs here, but even those are being phased out thanks to the internet. Cutbacks will surely include a reduction in advertising (thank God!). What we tend to ‘produce’ now in the US are services and intellectual property (something large parts of the rest of the world do not even recognise). The MPAA and RIAA members really do not have much cost tied up in production so they can easily reduce prices along with the reduction in demand. Many service industries (like medical) are simply not discretionary spending – so they are safe.

What is really going on here and is it something to worry about? It will not be painless, but all I see is a reduction of this mindless consumerism that is destroying the planet. As technology progresses we will eventually have to face the prospect that most people will not have to have jobs – and I’m not talking about living on the dole either. There simply will be very little reason to ‘work’. It is going to happen and when it does we had better be socially ready for the consequences. Perhaps a bit of deflation will serve as a test of how we will deal with our inevitable future.

My moon photos on Discovery Channel

Tuesday, December 2nd, 2008

I was contacted several weeks ago about the use of some of my Moon photographs for a TV show. They were looking for photos of lava tubes. Of course, the most easily seen ones are collapsed tubes, but they did not care. They saw some of my photos while they were mining flickr. We exchanged emails and refined what they were looking for and I happened to mention that I also had some movies of the moon. So, I sent them several photos and an AVI. I’m not really sure what if anything they used, but given the fact that I just got an email announcing the premier of the show just moments ago, I can only surmise that something was use in production. The show, Sci-Trek: Mining the Moon, will premiere on the Discovery Channel Thursday, December 11 at 10 pm ET/PT!