All Projects → fogleman → contourmap

fogleman / contourmap

Licence: MIT license
Compute contour lines (isolines) for any 2D data in Go.

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to contourmap

srtm-stylesheets
Shell scripts for working with NASA SRTM DEM data; gdaldem stylesheets for shaded relief maps; Mapnik stylesheets for contours; TileStache configuration for sandwich
Stars: ✭ 50 (-12.28%)
Mutual labels:  contours
R-CNN LIGHT
Regional-Convolution Neural Network for blink detection based on contouring.
Stars: ✭ 66 (+15.79%)
Mutual labels:  contours
pyefd
Python implementation of "Elliptic Fourier Features of a Closed Contour"
Stars: ✭ 71 (+24.56%)
Mutual labels:  contours
contour-rs
Contour polygon creation in Rust (using marching squares algorithm)
Stars: ✭ 33 (-42.11%)
Mutual labels:  contours
terrain
Generate contours, hillshade, Terrain RGB, slope-angle shading tiles from elevation data.
Stars: ✭ 33 (-42.11%)
Mutual labels:  contours
DICOMautomaton
A multipurpose tool for medical physics.
Stars: ✭ 35 (-38.6%)
Mutual labels:  contours
Webcam Paint OpenCV
This Python application uses OpenCV library to track an object-of-interest (water bottle cap in my case) and uses the detected object to draw colored lines (Blue, Green, Red and Yellow).
Stars: ✭ 66 (+15.79%)
Mutual labels:  contours
project sunroof india
Analyzed Google Satellite images to generate a report on individual house rooftop's solar power potential
Stars: ✭ 74 (+29.82%)
Mutual labels:  contours

contourmap

Compute contour lines (isolines) for any 2D data in Go.

Installation

go get -u github.com/fogleman/contourmap

Documentation

https://godoc.org/github.com/fogleman/contourmap

Example Usage

Creating a ContourMap

A new ContourMap can be generated in many different ways, depending on what type of data you have.

Use FromFloat64s if you have an array of numbers. The length of the array must equal width * height. The two-dimensional data is stored in a flat array in row-major order.

m := contourmap.FromFloat64s(width, height, data)

Use FromImage if you have an image.Image, such as a grayscale heightmap.

m := contourmap.FromImage(im)

Use FromFunction to specify an arbitrary function that will provide a Z for any given X, Y coordinate. The function will be called for all points x = [0, w) and y = [0, h) to determine the Z value at each point in the grid.

var f func(x, y int) float64
...
m := contourmap.FromFunction(width, height, f)

Finding Contour Lines

Once your ContourMap is created, you can use the Contours function to find isolines at any given Z height. This function returns a list of contours where each contour is a list of X, Y points. A Contour may be open or closed. Closed contours have c[0] == c[len(c)-1].

contours := m.Contours(z)
for _, contour := range contours {
    for _, point := range contour {
        // do something with points...
        fmt.Println(point.X, point.Y)
    }
}

Closing Contours at the Grid Perimeter

Contours may end at the edge of the grid data, forming open contours. If you want to force all contours to be closed by following the perimeter of the grid, you can use ContourMap.Closed which will generate a new ContourMap that can be used for this purpose:

m = m.Closed() // now all contours will be closed paths

Examples

Some examples are included to help you get started.

$ cd go/src/github.com/fogleman/contourmap/examples
$ go run iceland.go iceland.jpg

Iceland Example

$ go run examples/function.go

Function Example

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].