Here is a beautifully thresholded image of the night sky of 5 March, 2016.
![]() |
By the way, my T27 images are 27 minutes of arc across. A full moon would fit almost perfectly inside this box. |
This is not the original image as it came from the telescope. The original image has gray values that go from 0 to 65536, and on my screen it doesn't look like much.
In fact, the original looks like this:
Of course the original actually has much more dynamic range than my thresholded (I call it "sliced") version, but I don't care.
I don't care because:
- My monitor can't display it.
- My eyes can't see it.
- My image manipulation tools can't handle it worth a damn. (Maybe yje next version of the Gimp will do better.)
- My algorithms need it. The things I'm looking for are all down near the noise.
Actually, it has been two-way, thresholded. Like so.
Here is a histogram of the original image. (On the x-axis it has gray-values, on the y-axis it shows how many pixels of that gray value are in the image.)
The graph actually goes all the way to 65535 on the right, but the little bumps of pixels up there are so small you can't see them on this scale. The big normal distribution of pixels you are seeing here is the Dark Night Sky -- which contains practically all the pixels in the image.
But my 8-bit sliced image only has 256 gray values, so here is what I did:
The question is -- how can we automate this process? I want to write software to do all this with no human intervention, so that my software can find asteroids while I sit on a beach and sip Piña Coladas. So -- how can we find a nice threshold without me clicking on stuff with a mouse?
The trick is in the structure of that histogram. Because we are looking at the night sky, it will always look like that: a great huge normal distribution of pixels down in the dark, and teensy smattering of pixels all the way to the right.
How can we describe the ideal threshold position, relative to the structure of that histogram?
The criteria for the Magic Spot are structural criteria: aspects of the structure of this histogram. We want a spot that has a rapid descent on its left, but where the histogram is nice and flat to its right.
To find that kind of structure, we will create a structuring element. Since the space we are looking at is one-dimensional (it's actually just a list of numbers) our structuring element will also be one-dimensional. It will be two line segments, one to the left of the-point-we-are-looking-at-in-the-histogram, and one to the right.
The two halves of the structuring element both contribute to the total score for the point in the histogram that we are considering, but they do so in very different ways. The left half generates a high score if the part of the histogram that it is overlaying has a large drop in value from left to right. The right part of the structuring element generates a high score only if its part of the histogram is nice and flat. Between the two of these, they generate the highest score right at the place where we want to start our 8-bit, 256 grayvalue image: the right knee of the histogram's big curve.
By the way, the right half of the structuring element is not looking at the original histogram -- it's looking at the first derivative of the histogram. It just adds up all the values of the first derivative that fall under it, and thus gets an idea of the net up or down movement of the part of the histo it is on.
But here's a problem.
How big should this structuring element be? I don't want to assign it an arbitrary size that I simply know will work (like I did at first, during development.)
We want to ensure that the left half of the structuring element covers a good fraction of the right half of the Big Curve, but we don't want it to exceed half of the Big Curve's 'wavelength'. And we want to be able to determine the size fairly easily, because we are inherently lazy.
So let's just do this:
It's easy to find the highest point in the histogram, and easy to walk to the right until the value has fallen to half of the maximum. The distance we move rightward is a nice size for the left half of my structuring element, and we might as well use the same size for the right half.
Using that strategy for sizing the structuring element, and using the structuring element to find me my lower threshold for the 8-bit image 'slice' is what gave me these lovely images: (these are small crops from the main image)
Notice how, in this 3-frame movie, the background brightness doesn't change at all. The auto-thresholder found good thresholds on all three images, even though the background brightness of the sky was increasing during the 30 minutes I was taking the pictures. (I think the humidity was increasing, or something.)
Also notice how the trapezoid of stars in the upper left is preserved. Those are some of the dimmest objects in the images, and the threshold is doing a good job of not knocking them out.
This is the thresholder I will be using, until it dies or I find somebody better.
No comments:
Post a Comment