Module: Compix

Defined in:
lib/compix.rb,
ext/compix/compix.c

Defined Under Namespace

Classes: SubimageMatch

Class Method Summary collapse

Class Method Details

.find_all_instances_of_subimage(subimage, image, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/compix.rb', line 5

def self.find_all_instances_of_subimage(subimage, image, options={})
  options[:start_coordinate_x] ||= 0
  options[:start_coordinate_y] ||= 0
  matches = []

  subimage_match = self.find_subimage(subimage, image, options)
  while subimage_match.match?
    skip = false
    matches.each do |match|
      if match.overlaped_by?(subimage_match)
        skip = true
        break
      end
    end
    matches << subimage_match unless skip
    options[:start_coordinate_y] = subimage_match.coordinate_y
    options[:start_coordinate_x] = subimage_match.coordinate_x + subimage.width
    subimage_match = self.find_subimage(subimage, image, options)
  end
  matches
end

.find_subimageObject