border

package
v0.0.0-...-d3e05a1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 27, 2023 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

View Source
const (
	Outer = 0
	Hole  = 1
)

Variables

This section is empty.

Functions

func ContourStats

func ContourStats(c *Contour, offset int)

ContourStats generates writes to stdout stats about the contour and all children. Primarily used for debugging

func ContourStatsWithCollisions

func ContourStatsWithCollisions(c *Contour, offset int)

ContourStatsWithCollisions generates writes to stdout stats about the contour and all children that have collisions Primarily used for debugging.

func SaveContourSliceImage

func SaveContourSliceImage(filename string, c *Contour, width int, height int, flipBook bool, minContourSize int) error

SaveContourSliceImage saves a contour (and all child contours) as a PNG.

func SaveImage

func SaveImage(filename string, si *SuzukiImage) error

SaveImage saves a SuzukiImage to filename

Types

type Contour

type Contour struct {

	// Points making up the contour
	Points []image.Point

	Id int

	// Outer or Hole.
	BorderType int

	// Id of parent
	ParentId int

	// ParentCollision indicates if colliding with parent. Just an optimisation for quick removal later on.
	ParentCollision bool

	// Parent links to contours parent
	Parent *Contour

	// Children links to contours children
	Children []*Contour

	// ConflictingContours is a map of contours that we KNOW we conflict with. This may be the parent or other
	// siblings
	ConflictingContours map[int]bool // hate to use maps here... but want uniqueness

	// usable or not. Not filtering out but marking that we may not use it. (say if we're conflicting with another contour)
	Usable bool
}

Contour represents a single contour/border extracted from an image. It also tracks its parents and children.

func FindContours

func FindContours(img *SuzukiImage) *Contour

FindContours takes a SuzukiImage (basic 2d slice) and determines the Contours that are present. It returns the single parent contour which in turn has all other contours as children or further generations.

func NewContour

func NewContour(id int) *Contour

NewContour create new contour

func (*Contour) AddPoint

func (c *Contour) AddPoint(p image.Point) error

AddPoint adds a point (image.Point) to the contour

type SuzukiImage

type SuzukiImage struct {
	Width  int
	Height int
	// contains filtered or unexported fields
}

SuzukiImage is the basic structure we use to define an image. Will probably replace with something more optimal if required

func LoadImage

func LoadImage(filename string, erode bool) (*SuzukiImage, error)

LoadImage loads a PNG and returns a SuzukiImage. This may change since SuzukiImage may not really be required. erode flag forces the eroding of the image before converting to a SuzukiImage. This is to remove any "spikes" that may appear in the generated boundary.

func NewSuzukiImage

func NewSuzukiImage(width int, height int) *SuzukiImage

NewSuzukiImage creates a new SuzukiImage of specific dimentions.

func (*SuzukiImage) DisplayAsText

func (si *SuzukiImage) DisplayAsText() []string

DisplayAsText generates a string of a given image. This is purely used for debugging SMALL images

func (*SuzukiImage) Get

func (si *SuzukiImage) Get(p image.Point) int

Get returns the value of a given point

func (*SuzukiImage) GetXY

func (si *SuzukiImage) GetXY(x int, y int) int

GetXY returns the value of a given x/y

func (*SuzukiImage) Set

func (si *SuzukiImage) Set(p image.Point, val int)

Set sets the value at a given point

func (*SuzukiImage) SetXY

func (si *SuzukiImage) SetXY(x int, y int, val int)

SetXY sets the value at a given x/y

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL