Skip to content

Instantly share code, notes, and snippets.

@wedesoft
Created October 8, 2015 12:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wedesoft/22bc917f65e65c284b15 to your computer and use it in GitHub Desktop.
Save wedesoft/22bc917f65e65c284b15 to your computer and use it in GitHub Desktop.
Count bright pixels
#!/usr/bin/env ruby
require 'hornetseye_rmagick'
require 'hornetseye_xorg'
include Hornetseye
img = MultiArray.load_ubyte 'http://www.shu.ac.uk/research/meri/sites/shu.ac.uk/files/Fabio2%20case%20study.jpg'
sparks = (img >= 200).to_ubyte.sum
puts "about #{sparks} sparkly pixels"
puts "your milling tool is toast" if sparks >= 200
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment