Created
March 28, 2012 00:42
-
-
Save arirusso/2222231 to your computer and use it in GitHub Desktop.
ruby-processing: video capture w/ saturation filter
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
#!/usr/bin/env ruby | |
# only show pixels that pass a certain threshold of color saturation | |
class SaturationFilter < Processing::App | |
load_library :video | |
include_package "processing.video" | |
def setup | |
smooth | |
size(720, 576, P2D) | |
@video = Capture.new(self, width, height, 30) | |
end | |
def draw | |
@video.read if @video.available? | |
image(@video, 0, 0) | |
load_pixels | |
black = color(0,0,0) | |
pixels.each_with_index do |p,i| | |
pixels[i] = black unless [red(p), green(p), blue(p)].any? { |n| n > 80 } | |
end | |
update_pixels | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment