Answer the question
In order to leave comments, you need to log in
How to count the number of stars in the night sky?
I have a photo of the night sky:
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):
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.
There are small interferences, but they do not play an important role. Can be credited to the stars.
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.
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?
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question