Created
October 8, 2015 12:40
-
-
Save wedesoft/22bc917f65e65c284b15 to your computer and use it in GitHub Desktop.
Count bright pixels
This file contains 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
#!/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