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() |
google an image of sky at night, using libraries in this script, you can count the number of starts in the image.
hey! I got that. I even tried and it works fine. Was asking about the code tho. Could you explain the lines of code?
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.
Thanks, mate! stay blessed.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
would you mind explaining it a bit ?