Documentation ¶
Index ¶
- func AnimateThreshold(img []int, rows, steps int, outfile string)
- func GetImage(filename string) ([]int, int)
- type ConvexPeel
- func (cp *ConvexPeel) Area() float64
- func (cp *ConvexPeel) Centroid() [2]float64
- func (cp *ConvexPeel) HullPoints(buf [][2]float64) [][2]float64
- func (cp *ConvexPeel) NumPoints() int
- func (cp *ConvexPeel) Peel()
- func (cp *ConvexPeel) PeelTo(frac float64)
- func (cp *ConvexPeel) Perimeter() float64
- func (cp *ConvexPeel) Reset()
- func (cp *ConvexPeel) Stats(depth []float64) []Stat
- type ConvexPeelPlot
- type Label
- type Landscape
- type LandscapePlot
- type Persistence
- type Pstate
- type Stat
- type Trajectory
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnimateThreshold ¶
AnimateThreshold constructs an animated PNG showing a sequence of thresholded versions of an image. The image pixel data are provided as a slice of integers, which must conform to a rectangular image with the given number of rows. The animation is based on a series of steps in which the image is thresholded at a linear sequence of values ranging from the minimum to the maximum pixel intensity. The image is written in animated png (.apng) format to the given file.
Types ¶
type ConvexPeel ¶
type ConvexPeel struct {
// contains filtered or unexported fields
}
ConvexPeel supports calculation of a sequence of convex hulls for a point set.
func NewConvexPeel ¶
func NewConvexPeel(x, y []float64) *ConvexPeel
NewConvexPeel calculates a sequence of peeled convex hulls for the given points.
func (*ConvexPeel) Area ¶
func (cp *ConvexPeel) Area() float64
Area returns the area of the current convex hull.
func (*ConvexPeel) Centroid ¶
func (cp *ConvexPeel) Centroid() [2]float64
Centroid returns the centroid of the current point set, i.e. the points that have not been peeled.
func (*ConvexPeel) HullPoints ¶
func (cp *ConvexPeel) HullPoints(buf [][2]float64) [][2]float64
HullPoints returns the points that are on the current convex hull.
func (*ConvexPeel) NumPoints ¶
func (cp *ConvexPeel) NumPoints() int
NumPoints returns the number of active points (i.e. the number of points that have not been peeled).
func (*ConvexPeel) Peel ¶
func (cp *ConvexPeel) Peel()
Peel removes the current hull points and recomputes the hull.
func (*ConvexPeel) PeelTo ¶
func (cp *ConvexPeel) PeelTo(frac float64)
PeelTo peels until no more than the given fraction of points remains.
func (*ConvexPeel) Perimeter ¶
func (cp *ConvexPeel) Perimeter() float64
Perimeter returns the perimeter of the current convex hull.
func (*ConvexPeel) Reset ¶
func (cp *ConvexPeel) Reset()
Reset returns to the original state, with no points having been peeled.
func (*ConvexPeel) Stats ¶
func (cp *ConvexPeel) Stats(depth []float64) []Stat
Stats obtains the area, perimeter, and centroid for a series of convex peel profiles of a point set. The convex peel is constructed for a grid of npoints depth values spanning from from high to low.
type ConvexPeelPlot ¶
type ConvexPeelPlot struct { // Input image file name, should be a png or jpeg image file Filename string // Output filename for the plot, suffix determines format Outfile string // The number of image thresholding steps Isteps int // Plot these convex peel fractions (e.g. Depth=0.95 trims off 5% of the data) Depth []float64 }
ConvexPeelPlot supports constructing plots of convex hull peels.
func (*ConvexPeelPlot) Plot ¶
func (cpp *ConvexPeelPlot) Plot()
Plot generates a plot of a set of birth/death times along with several convex hull peels.
type Label ¶
type Label struct {
// contains filtered or unexported fields
}
Label finds the connected components in a binary image.
func NewLabel ¶
NewLabel finds the connected components of a given binary image (mask), which is rectangular with the given number of rows. buf is an optional memory buffer having the same length as mask. Use the methods of the returned Label value to obtain information about the labels.
The algorithm implemented here is the run-based algorithm of He et al. (2008), IEEE Transactions on Image Processing, 17:5. https://ieeexplore.ieee.org/stamp/stamp.jsp?tp=&arnumber=4472694
func (*Label) Bboxes ¶
Bboxes returns the bounding boxes for every labeled component. The bounding box for the component with label k is held in position k of the returned slice. The provided slice is used if large enough.
func (*Label) NumComponents ¶
NumComponents returns the number of components, including the background component. The maximum component label is one less than the number of components.
type Landscape ¶
type Landscape struct {
// contains filtered or unexported fields
}
Landscape supports construction of landscape diagrams for describing the persistence homology of an image.
func NewLandscape ¶
NewLandscape returns a Landscape value for the given object birth and death times. Call the Eval method to evaluate the landscape function at prescribed depths.
type LandscapePlot ¶
type LandscapePlot struct { // Input image file name, should be a png or jpeg image file Filename string // Output filename for the plot, suffix determines format Outfile string // The number of image thresholding steps Isteps int // The number of steps along the landscape profile Lsteps int // Plot these landscape depths Depth []int }
LandscapePlot supports creation of plots of landscape functions.
func (*LandscapePlot) Plot ¶
func (lsp *LandscapePlot) Plot()
Plot generates a landscape plom a LandscapePlot value.
type Persistence ¶
type Persistence struct {
// contains filtered or unexported fields
}
Persistence constructs object persistence trajectories for an image.
func NewPersistence ¶
func NewPersistence(img []int, rows, steps int) *Persistence
NewPersistence calculates an object persistence diagram for the given image, which must be rectangular with the given number of rows. The steps argument determines the threshold increments used to produce the persistence diagram.
func (*Persistence) BirthDeath ¶
func (ps *Persistence) BirthDeath() ([]float64, []float64)
BirthDeath returns the object birth and death times as float64 slices.
func (*Persistence) Labels ¶
func (ps *Persistence) Labels() []int
Labels returns the current object labels.
func (*Persistence) Sort ¶
func (ps *Persistence) Sort()
Sort gives a deterministic order to the persistence trajectories.
func (*Persistence) Trajectories ¶
func (ps *Persistence) Trajectories() []Trajectory
Trajectories returns the persistence trajectories. Each outer element of the returned slice is a sequence of states defining a trajectory. The order of the trajectories may be non-deterministic, calling Sort before calling Trajectories ensures a deterministic order.
type Pstate ¶
type Pstate struct { // The connected component label for the object (not // comparable across points on a trajectory). Label int // The size in pixels of the object. Size int // The maximum intensity of the object. Max int // The step of the algorithm at which the state is defined. Step int // The threshold used to define the image used at this step of // the algorithm. Threshold int // A bounding box for the object Bbox image.Rectangle }
Pstate defines a state in a persistence trajectory.
type Stat ¶
Stat contains summary statistics about a landscape or convex peel profile at a given depth.
type Trajectory ¶
type Trajectory []Pstate
Trajectory is a sequence of persistence states defined by labeling an image thresholded at an increasing sequence of threshold values.