Class: Imatcher::Modes::RGB
- Inherits:
-
Base
- Object
- Base
- Imatcher::Modes::RGB
show all
- Defined in:
- lib/imatcher/modes/rgb.rb
Overview
Compare pixels by values.
Resulting image contains per-channel differences.
Instance Attribute Summary
Attributes inherited from Base
#result, #threshold
Instance Method Summary
collapse
Methods inherited from Base
#calculate_bounds, #compare, #diff, #initialize, #score
#brightness
Instance Method Details
#background(bg) ⇒ Object
16
17
18
|
# File 'lib/imatcher/modes/rgb.rb', line 16
def background(bg)
Image.new(bg.width, bg.height, BLACK)
end
|
#create_diff_image(bg, diff_image) ⇒ Object
20
21
22
|
# File 'lib/imatcher/modes/rgb.rb', line 20
def create_diff_image(bg, diff_image)
bg.to_grayscale.compose!(diff_image, 0, 0)
end
|
#pixels_diff(d, a, b, x, y) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/imatcher/modes/rgb.rb', line 24
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
|
# File 'lib/imatcher/modes/rgb.rb', line 12
def update_result(a, b, x, y)
@result.diff << [a, b, x, y]
end
|