Finding Flares

For the purposes of this project, I use the term “Flare” to specify an unexpectedly bright pixel. I use the first twenty frames of a video to determine a value for every pixel (all two million of them) of the mean and standard deviation of its luminance. For every pixel in the frame, I read the actual luminance and compare it with the mean. If it is four times greater than the mean plus standard deviation, then I identify that pixel as a “Seed”. 

The next step is to explore pixels neighboring the seed to determine if they are also unexpectedly bright. To do this I use a recursive algorithm. Starting at the seed, I examine each of the four pixels immediately adjacent to the seed pixel:

Seed

In this example, the algorithm might reject all but the pixel underneath the seed pixel. Then it would move to that new pixel and treat it the same way it treated the seed pixel:

seed2

Now it would take the pixel to the left of this second pixel, and proceed on from there until it ran out of unexpectedly bright pixels. This might produce a group of pixels roughly like this:

MeteorBlob

My objective is to determine the slope of a line running through the middle of the flare:

LineThroughBlob

I can calculate this value from some simple equations.

But I ran into a killer problem: you will note that the blob of pixels isn’t a nice, neat sausage. It has dents and protrusions. These come from slight variations in the camera’s sensor, and they can throw off the calculation of the slope. I had one case where the slope was way, way off due to this problem.

After much hand-wringing, I decided upon an algorithm in which I use only the 100 brightest pixels in the blob, throwing away all the other pixels. This, I think, should confine the blob to the core of the image. I may have to modify the algorithm, taking 200 pixels, perhaps, or perhaps the brightest 20% of the pixels — I’ll have to experiment.

November 14th: Slope Algorithms
So far I’m not getting acceptable results. Here are the slopes and correlation coefficient values for the images of the test meteor in the frames:

-1.1451594678186925

-1.0943293575143855

-0.8413195531892682

-0.730959806435413

-0.4986777867592886

-0.9668364347916221

-0.7723705146951009 and r of -0.4687176242584158

-0.5569939445817493 and r of -0.43988711219315524

-0.6373696420169925 and r of -0.5363372964955483

-0.661722258873388 and r of -0.5694420673896362

-0.6959243636202898 and r of -0.5555831585529614

-0.6085224979141084 and r of -0.526604653707855

-0.6194355224986414 and r of -0.5496517841938392

-0.5670152387563754 and r of -0.43757293738653813

-0.6187851104331143 and r of -0.33944815016855817

-1.593833780160858 and r of -0.8441274816601102

-0.548112113206976 and r of -0.4407924880908273

-0.4803982241100141 and r of -0.3677826114854598

-0.44379691557394313 and r of -0.3621798292736877

-0.4440328153826384 and r of -0.41194493767656387

-0.5161408507304733 and r of -0.45502048651576427

-0.456456945629172 and r of -0.4394767640013762

-0.49315951411723113 and r of -0.479387449772714

-0.4374441413145003 and r of -0.49131176117819464

-0.5883641578587655 and r of -0.5172124708535534

-0.6609191957934216 and r of -0.5587248136285203

-0.9806560538725745 and r of -0.7413896883647072

-0.9449593055312655 and r of -0.7809718224762497

-0.8470612653024759 and r of -0.6738766682701205

-0.8479715240293789 and r of -0.8766171329418567

-0.837068625201775 and r of -0.7940326833173348

As you can see, the slopes wiggle around badly and the r-values are just as bad. I checked my equations and confirmed that they are correct representations of the standard equations. I tried using values weighted by the luminance of each pixel, but that didn’t help.

So I decided to go back and look at the data again. Here’s a compilation showing all the individual images of the meteor smashed into a single frame:

MashedMeteor

You can readily see that they fit together nicely with no gaps. There’s even some overlap from the tiny trail the meteor leaves when it gets bright.

But then I tried something different: I converted the slopes into angles (using arctangent), then plotted the angles for each of four frames, with this result:

MeteorAngles

Well, golly gee willikers! The angles aren’t so bad after all. I was obsessing over differences in slopes when the differences between angles really weren’t that bad. So now I’m going to re-run a number of tests of different algorithms, getting their angles rather than their slopes. Let’s see how that works.

It works great! OK, this problem is now something I can put aside, because there’s one more major problem to solve: calculating the position of the frame in the sky. I already have right ascensions and declinations of many stars in each frame, but I must be able to calculate the position values of points on the meteor track. 

Actually, that’s not critical. What’s critical are the directions in which the meteors are moving. This is fundamental to identifying those meteors that are members of known meteor showers. The problem is best illustrated with one of the star maps that I made from one of the frames from a video:

It’s a little difficult to make out the contents of this frame, so here’s a closeup of part of it:

SmallGreatMap

This is an inverted star image; astronomers have found that these are easier to work with than the normal black-background images. 

Each star is a black dot; brighter stars are bigger. I have labeled some of the stars with their number from the Henry Draper catalog, a catalog of stars compiled more than a century ago. It contains more than 25,000 stars, and the catalog consumes 13 MB of storage space. I identify each star by its number in the catalog. Thus the star nearest the center marked in red is HD 186901. Its right ascension is 19 hours, 42 minutes, and its declination is 35º 51’. Various colors indicate technical arcana that are irrelevant to this matter. But crucial to note are the two horizontal green lines and the vertical brown line. The green lines denote what I estimated to be lines of equal declination, while the brown line denotes what I believe to be a line of equal right ascension.

Here’s the problem: those green lines are not quite horizontal and the brown line is not quite vertical. I tried very hard to line up my camera to be exactly aligned with the Pole Star, but obviously I missed by a few degrees. If could base my calculations on the knowledge that the image is perfectly aligned, my calculations are easy. But that slight misalignment makes my calculations much messier.