border

package
v0.0.0-...-0439720 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2024 License: Apache-2.0 Imports: 10 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 LoadImage

func LoadImage(filename string, erode int, dilate int) (*common.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 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 *common.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 *common.SuzukiImage) (*Contour, error)

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

Jump to

Keyboard shortcuts

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