Created
May 4, 2016 19:53
-
-
Save hackerdem/cf5ff212ef1a0bced869b661244a11c5 to your computer and use it in GitHub Desktop.
Count stars on a photo using python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import pylab | |
import mahotas as mh | |
from skimage import measure | |
sky=mh.imread('sky.jpeg') | |
pylab.imshow(sky) | |
t=mh.thresholding.otsu(sky.astype('uint8')) | |
labeled,stars=mh.label(sky>t) | |
print stars | |
pylab.imshow(labeled) | |
pylab.jet() | |
pylab.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It has been a long time, I don't remember line by line, but what it does this; it reads the image in terms of colour density,then based on a threshold you would define, it will count the areas which are brighter than the rest of image, so every dot in your image depending on the threshold in terms of size will be counted.