Class: ColorDecomposition::Quadtree

Inherits:
Object
  • Object
show all
Defined in:
lib/color_decomposition/quadtree/quadtree.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(width, height) ⇒ Quadtree

Returns a new instance of Quadtree.



7
8
9
# File 'lib/color_decomposition/quadtree/quadtree.rb', line 7

def initialize(width, height)
  @root = Node.new(left: 0, top: 0, right: width, bottom: height)
end

Instance Attribute Details

#rootObject (readonly)

Returns the value of attribute root.



5
6
7
# File 'lib/color_decomposition/quadtree/quadtree.rb', line 5

def root
  @root
end

Instance Method Details

#base_nodesObject



11
12
13
14
# File 'lib/color_decomposition/quadtree/quadtree.rb', line 11

def base_nodes
  generate_to_base(nodes = [], max_level)
  nodes
end

#generate_similarity_tree(similarity) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/color_decomposition/quadtree/quadtree.rb', line 16

def generate_similarity_tree(similarity)
  level = max_level - 1
  level.times do
    nodes_from_level(nodes = [], level)
    nodes.each do |node|
      node.merge if node.child_leaves? && node.similar?(similarity)
    end
    level -= 1
  end
end