Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.