Skip to content

Instantly share code, notes, and snippets.

@arirusso
Created March 28, 2012 00:42
Show Gist options
  • Save arirusso/2222231 to your computer and use it in GitHub Desktop.
Save arirusso/2222231 to your computer and use it in GitHub Desktop.
ruby-processing: video capture w/ saturation filter
#!/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