Class: Imatcher::Modes::RGB
Overview
Compare pixels by values. Resulting image contains per-channel differences.
Instance Attribute Summary
Attributes inherited from Base
#bounds, #exclude_rect, #include_rect, #result, #threshold
Instance Method Summary collapse
- #background(bg) ⇒ Object
- #create_diff_image(_bg, diff_image) ⇒ Object
- #pixels_diff(d, a, b, x, y) ⇒ Object
- #pixels_equal?(a, b) ⇒ Boolean
- #update_result(a, b, x, y) ⇒ Object
Methods inherited from Base
#area, #compare, #diff, #initialize, #score, #update_bounds
Methods included from ColorMethods
#blue, #brightness, #green, #red
Constructor Details
This class inherits a constructor from Imatcher::Modes::Base
Instance Method Details
#background(bg) ⇒ Object
17 18 19 |
# File 'lib/imatcher/modes/rgb.rb', line 17 def background(bg) Image.new(bg.width, bg.height, BLACK) end |
#create_diff_image(_bg, diff_image) ⇒ Object
21 22 23 |
# File 'lib/imatcher/modes/rgb.rb', line 21 def create_diff_image(_bg, diff_image) diff_image end |
#pixels_diff(d, a, b, x, y) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/imatcher/modes/rgb.rb', line 25 def pixels_diff(d, a, b, x, y) d[x, y] = rgb( (r(a) - r(b)).abs, (g(a) - g(b)).abs, (b(a) - b(b)).abs ) end |
#pixels_equal?(a, b) ⇒ Boolean
8 9 10 |
# File 'lib/imatcher/modes/rgb.rb', line 8 def pixels_equal?(a, b) a == b end |
#update_result(a, b, x, y) ⇒ Object
12 13 14 15 |
# File 'lib/imatcher/modes/rgb.rb', line 12 def update_result(a, b, x, y) super @result.diff << [a, b, x, y] end |