:pushpin: State of the art point location and neighbour finding algorithms for region quadtrees, in Go

Region quadtrees in Go

Build Status Coverage Status Go Report Card GoDoc

Region quadtrees and efficient neighbour finding techniques in Go

Go-rquad proposes various implementations of region quadtrees.

A region quadtree is a special kind of quadtree that recursively subdivides a 2 dimensional space into 4 smaller and generally equal rectangular regions, until the wanted quadtree resolution has been reached, or no further subdivisions can be performed.

Region quadtrees can be used for image processing; in this case a leaf node represents a rectangular region of an image in which all colors are equal or the color difference is under a given threshold.

Region quadtrees may also be used to represent data fields with variable resolution. For example, the temperatures in an area may be stored as a quadtree where each leaf node stores the average temperature over the subregion it represents.

In this package, quadtrees implement the imgscan.Scanner interface, this provides a way to scan (i.e extract) the pixels in order to perform the subdivisions.

API Overview

Node interface

type Node interface {
        Parent() Node
        Child(Quadrant) Node
        Bounds() image.Rectangle
        Color() Color
        Location() Quadrant
}

Quadtree interface

A Quadtree represents a hierarchical collection of Nodes, its API is simple: access to the root Node and a way to iterate over all the leaves.

type Quadtree interface {
        ForEachLeaf(Color, func(Node))
        Root() Node
}

Functions

Locate returns the leaf node of q that contains pt, or nil if q doesn't contain pt.

func Locate(q Quadtree, pt image.Point) Node

ForEachNeighbour calls fn for each neighbour of n.

func ForEachNeighbour(n Node, fn func(Node))

Basic implementation: BasicTree and basicNode

BasicTree is in many ways the standard implementation of Quadtree, it just does the job.

State of the art implementation: CNTree and CNNode

CNTree or Cardinal Neighbour Quadtree implements state of the art techniques:

  • from any given leaf node, its neighbours (of any size) are accessed in constant time 0(1) as they implement the Cardinal Neighbour Quadtree technique (cf Safwan Qasem 2015). The time complexity reduction is obtained through the addition of only four pointers per leaf node in the quadtree.
  • fast point location queries (locating which leaf node contains a specific point), thanks to the binary branching method (cf Frisken Perry 2002). This simple and efficient method is nonrecursive, table free, and reduces the number of comparisons with poor predictive behavior, that are otherwise required with the standard method.

Benchmarks

Quadtree creation benchmark

Neighbour finding benchmark

Point location benchmark

Research papers

  • Bottom-up neighour finding technique. cf Hanan Samet 1981,
    Neighbor Finding Techniques for Images Represented by Quadtrees, paper

  • Cardinal Neighbor Quadtree. cf Safwan Qasem 2015,
    Cardinal Neighbor Quadtree: a New Quadtree-based Structure for Constant-Time Neighbor Finding, paper

  • Fast point location using binary branching method. cf Frisken, Perry 2002
    Simple and Efficient Traversal Methods for Quadtrees and Octrees, paper

License

go-rquad is open source software distributed in accordance with the MIT License, which says:

Copyright (c) 2016 Aurélien Rainone

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Owner
Similar Resources

Algorithms and Data Structures Solved in Golang

Algorithms and Data Structures Solved in Golang Hi! I'm Bruno Melo and this repository contains a lot challenges solved on many plataforms using go as

Oct 20, 2022

Some data structures and algorithms using golang

Some data structures and algorithms using golang

Aug 13, 2022

Data structures and algorithms implementation from ZeroToMastery course

ZeroToMastery Data Structures & Algorithms course This repo includes all the data structure and algorithm exercises solutions and implementations. Ins

Jul 4, 2022

Practice-dsa-go - Data Structures and Algorithms for Interview Preparation in Go

Data Structures and Algorithms for Interview Preparation in Go Data Structures K

Jul 3, 2022

Implementation of various data structures and algorithms in Go

Implementation of various data structures and algorithms in Go

GoDS (Go Data Structures) Implementation of various data structures and algorithms in Go. Data Structures Containers Lists ArrayList SinglyLinkedList

Jan 25, 2022

Data Structures and Algorithms implementation in Go

Data Structures and Algorithms Clean and simple implementation in Go Implementation There are several data structures and algorithms implemented in th

Jan 2, 2023

Graph algorithms written in Go

Graph Algorithms in Go This repository contains implementations of various graph algorithms written in Go. I’ve written them to learn about these algo

Dec 26, 2022

Some algorithms in go: maxflow(min-cuts or graph-cuts), edit-distance.

Algorithms In this repository, some algorithms are implemented in go language. GoDoc link: ed maxflow About Max-flow problem: A flow network is repres

Sep 8, 2022

fim is a collection of some popular frequent itemset mining algorithms implemented in Go.

fim fim is a collection of some popular frequent itemset mining algorithms implemented in Go. fim contains the implementations of the following algori

Jul 14, 2022
Comments
  • Polish api and doc

    Polish api and doc

    • too many files: merge related files, merge generated files with related files
    • polish documentation
    • polish readme: describe main point location, neighbour finding techniques implemented in go-rquad, if possible with images
    • show benchmark results
  • How were the diagrams generated?

    How were the diagrams generated?

    Hi and thank you for this project @aurelien-rainone ! :)

    How (using which tools) were the diagrams (eg https://raw.githubusercontent.com/aurelien-rainone/go-rquad/readme-docs/Creation.png) generated? They look so smooth!

  • Cardinal neighbour quadtree

    Cardinal neighbour quadtree

    Implement CNQuadtree, cardinal neighbour quadtree (cf paper Cardinal Neighbor Quadtree: a New Quadtree-based Structure for Constant-Time Neighbor Finding)

  • Replace local bmp package with binimg (vendored)

    Replace local bmp package with binimg (vendored)

    Remove all in bmp/ subpackage folder bmp is not a subpackage any more Replace bmp with github/aurelien-rainone/binimg pkg Quadtree benchmarks use binimg pkg Add govendor vendor.json: with binimg pkg Vendor binimg package

Go translations of the algorithms and clients in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin Wayne.

Overview Go translations of the Java source code for the algorithms and clients in the textbook Algorithms, 4th Edition by Robert Sedgewick and Kevin

Dec 13, 2022
Go native library for fast point tracking and K-Nearest queries

Geo Index Geo Index library Overview Splits the earth surface in a grid. At each cell we can store data, such as list of points, count of points, etc.

Dec 3, 2022
A generic Go library for implementations of tries (radix trees), state commitments and proofs of inclusion

trie.go Go library for implementations of tries (radix trees), state commitments and proof of inclusion for large data sets. It implements a generic 2

Aug 3, 2022
Finite State Machine for Go

FSM for Go FSM is a finite state machine for Go. It is heavily based on two FSM implementations: Javascript Finite State Machine, https://github.com/j

Dec 27, 2022
Package mafsa implements Minimal Acyclic Finite State Automata in Go, essentially a high-speed, memory-efficient, Unicode-friendly set of strings.

MA-FSA for Go Package mafsa implements Minimal Acyclic Finite State Automata (MA-FSA) with Minimal Perfect Hashing (MPH). Basically, it's a set of str

Oct 27, 2022
Go implementation of C++ STL iterators and algorithms.

iter Go implementation of C++ STL iterators and algorithms. Less hand-written loops, more expressive code. README translations: 简体中文 Motivation Althou

Dec 19, 2022
Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching.

Trie Data structure and relevant algorithms for extremely fast prefix/fuzzy string searching. Usage Create a Trie with: t := trie.New() Add Keys with:

Dec 27, 2022
Graph algorithms and data structures
Graph algorithms and data structures

Your basic graph Golang library of basic graph algorithms Topological ordering, image by David Eppstein, CC0 1.0. This library offers efficient and we

Jan 2, 2023
Graph algorithms and data structures
Graph algorithms and data structures

Your basic graph Golang library of basic graph algorithms Topological ordering, image by David Eppstein, CC0 1.0. This library offers efficient and we

Jan 25, 2021
Data Structure Libraries and Algorithms implementation

Algorithms Data Structure Libraries and Algorithms implementation in C++ Disclaimer This repository is meant to be used as a reference to learn data s

Dec 8, 2022