Identifying Stars in the Input Image

The first thing the HGP does is to completely read in the binary starfield image and store it in memory. The program also creates a blank grayscale image that will serve as the in memory hyperspace image, i.e. HI. It is the HI that will actually have the star streaks painted on it. The HI is the same size as the input binary starfield image except that it has an extra 40 pixel wide boarder completely around it so that the streaks can extend beyond the edge of the actual resulting image. This boarder will eventually be shaved off when the HI is actually written out to the disk.

The next step in the process is having the HGP identify the locations and sizes of all the stars in the binary starfield input image. This image processing task is not as easy as you might think. We humans are very visual creatures and we can process an image almost instantly because we process the whole image at once. We automatically see all the edges making up all the shapes in the scene being viewed. But computers can only look at things one pixel at a time so it is much more difficult for the machine to identify individual items in an image. Our task is somewhat simplified though because our image is only made up of pixels that can either be black or white.

Before we proceed, I made several assumptions that made the coding simpler. Assumption one is that for all the following discussion, we are going to be working in quadrant one of the 2D X-Y coordinate system. That means that increasing X axis values go to the right and increasing Y axis values go vertically up. Assumption two is that no star will overlap the pixel that represents the hyperspace jump point location on the input image. This will prevent undefined line segments from being specified. Assumption three is that no minimum bounding rectangle, i.e. MBR, of any two stars will overlap or even touch each other. This will prevent the HGP from thinking that two stars that are very close to each other are actually the same star. See the below diagram.

(Image)

With these assumptions, made we can now proceed with trying to figure out where the stars are. The algorithm for determining star locations works by processing each scanline of the input image separately. Then within each scanline, the HGP looks at each pixel in the scanline from left to right. If the current pixel is black, then the program just skips to the next pixel. If the next pixel is white, then the program must determine if this white pixel is the first pixel of a new star or if it is part of an already existing star that just has to be enlarged. If the pixel is identified as part of an already exiting star, then the pixel's X axis location along the scanline is used to expand the star's X axis MBR and the number of white pixels making up this star is incremented by one.

If it is determined that this pixel is not part of any star that is currently active then it is determined that this is a new star and a place is made for it in an array that stores information about all the stars that have been identified so far. A star is determined to be complete if the star's MBR lower Y axis limit is higher than the Y axis location of the current scanline + 1. If this is true, then the program has determined that there is a blank space between the star's lower Y axis MBR limit and the current scanline. That blank space means that the star is complete and therefore cannot have any more pixels added to it. See the diagram below. In the previous discussion, I have actually glossed over many important details about star identification, and the algorithm is in reality more complex than this.

(Image)


Last Updated: June 1, 2000
HTML URL: http://geocities.datacellar.net/~special_effect/hyperspace_is.html
E-Mail: special_effect@geocities.com or click here
1