Skip to content

Instantly share code, notes, and snippets.

@hackerdem
Created May 4, 2016 19:53
Show Gist options
  • Save hackerdem/cf5ff212ef1a0bced869b661244a11c5 to your computer and use it in GitHub Desktop.
Save hackerdem/cf5ff212ef1a0bced869b661244a11c5 to your computer and use it in GitHub Desktop.
Count stars on a photo using python
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()
@SaraJ52
Copy link

SaraJ52 commented Feb 27, 2021

Thanks, mate! stay blessed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment