I
I
imlynn2017-04-05 00:07:20
Images
imlynn, 2017-04-05 00:07:20

How to count the number of stars in the night sky?

I have a photo of the night sky:
b5d6534eec26456fb7ef1930890de920.jpg
The program leaves only those areas in the photo that meet a certain threshold, and in this way we can determine all the stars in the photo.
Let the following image be an example of this program and it meets all our requirements (actually not, but that's not the point):
fd33ee0274904edabdf7f23c862c2398.png
Now we need to determine how many stars there are in this photo and their size, while ignoring various noises.
The image is encoded into one long one-line array where the white areas correspond to "1" and the black areas to "0" (that's what we have to work with), but there is also a function that returns the color value of a particular pixel from it (let it look like this : pick(x,y) == 0 or 1).
The size of a star is the diameter of the circle superimposed on it. Those. for a star with one point, the size is 1, if it is a 2x2 square, then 2, if it is a 3x3 cross, then 3, and so on.
There are stars in the photo, which are shown as a straight line in the image. Yes, these are not circle coordinates, but if the line is less than 3 pixels long, then it is allowed. (example below)
A star is always a closed contour, and most of its points should lie in the coordinates of a circle, if not, this is a hindrance. But small distortions are also allowed. For understanding, compare the photo and the resulting images:
All marked areas are stars.
09a7a4bb4e5446099b630672cbf9ed62.png
There are small interferences, but they do not play an important role. Can be credited to the stars.
8d3d7387ca5f4181bb3fd1f09b3dd990.png
There are serious obstacles. Although the logic of the described, several areas still fall under the definition of a star. But this is not so important.
143e4f4385d744c6b20cd82937f71390.png
I thought to first use the contour search algorithm, apply masks to each point of the image and see if it corresponds to it. So it will even be possible to determine how many stars of what sizes there are ("small - 24, large - 14", etc.). But it's very tricky - to make a hundred masks for each size and compare like that.
Is there any way to do it nicely?

Comment
Я не требую от программы 100% точности, и даже гарантирую, что буду кормить ее изображениями с минимальными помехами, а то, что показано выше - только пример.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Roman Mindlin, 2017-04-05
@kgbplus

Try some kind of object clustering algorithm. How many clusters you get - about as many stars. Objects must be pixels with brightness above some threshold.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question