Documentation
¶
Index ¶
- func CirucularScan(image ImageMatrix) ([][]*Square, [][]ImageMatrix)
- func Col2im(x *mat64.Dense, d, r, c int) []*mat64.Dense
- func Convolve(x, k [][]*mat64.Dense, p, s int) [][]*mat64.Dense
- func EuclideanDistance(m1, m2 ImageMatrix) float64
- func Im2col(x []*mat64.Dense, p, s, kd, kr, kc int) *mat64.Dense
- func ImageMatrixToImage(imageArray ImageMatrix, outPath string, mul int) error
- func LeakyRelu(x float64, deriv bool) float64
- func LinearScan(data ImageMatrix) [][]ImageMatrix
- func MaxPool(x *mat64.Dense, fr, fc int) (*mat64.Dense, *mat64.Dense)
- func Prepare(targetPath string) error
- func ReadCSV(path string) ([][]string, error)
- func ReadImage(path string) (image.Image, error)
- func Relu(x float64, deriv bool) float64
- func Reshape2DTo2D(x *mat64.Dense, r, c int) *mat64.Dense
- func ReshapeKernel(x [][]*mat64.Dense) *mat64.Dense
- func ScanToStrings(p Predictor, image image.Image) []string
- func Sigmoid(x float64, deriv bool) float64
- func Train(sampleFolderPath string, modelPath string) error
- type CNNPredictor
- type Coordinate
- func (c *Coordinate) DistanceTo(c2 *Coordinate) float64
- func (c *Coordinate) E() *Coordinate
- func (c *Coordinate) HorizontalDistanceTo(c2 *Coordinate) float64
- func (c *Coordinate) IsInside(s *Square) bool
- func (c *Coordinate) N() *Coordinate
- func (c *Coordinate) NE() *Coordinate
- func (c *Coordinate) NW() *Coordinate
- func (c *Coordinate) S() *Coordinate
- func (c *Coordinate) SE() *Coordinate
- func (c *Coordinate) SW() *Coordinate
- func (c *Coordinate) VerticalDistanceTo(c2 *Coordinate) float64
- func (c *Coordinate) W() *Coordinate
- type Groups
- type ImageMatrix
- func AdaptiveThres(im ImageMatrix, bs int) ImageMatrix
- func ImageToGraysclaeArray(src image.Image) ImageMatrix
- func NewImageMatrix(r, c int) ImageMatrix
- func NewImageMatrixWithDefaultValue(r, c int, v uint8) ImageMatrix
- func OtsuThresh(im ImageMatrix) ImageMatrix
- func PadAndResize(matrix ImageMatrix, dr, dc int) ImageMatrix
- func SauvolaBinarization(imageArr ImageMatrix) ImageMatrix
- func Threshold(im ImageMatrix, thrs uint8) ImageMatrix
- func (i ImageMatrix) At(r, c int) uint8
- func (i ImageMatrix) AtCoordinate(c *Coordinate) uint8
- func (i ImageMatrix) Col(c int) ImageVector
- func (i ImageMatrix) Dims() (int, int)
- func (im ImageMatrix) Erode()
- func (im ImageMatrix) Historgram() []int
- func (i ImageMatrix) NNInterpolation(tr, tc int) ImageMatrix
- func (i ImageMatrix) Pad(top, bottom, left, right int, value uint8) ImageMatrix
- func (i ImageMatrix) Row(r int) ImageVector
- func (i ImageMatrix) Set(r, c int, value uint8)
- func (im ImageMatrix) SetSquare(s *Square, si ImageMatrix)
- func (i ImageMatrix) Slice(sr, er, sc, ec int) ImageMatrix
- func (im ImageMatrix) SliceSquare(s *Square) ImageMatrix
- type ImageMatrixs
- type ImageVector
- type Marker
- type Model
- type ModelImage
- type NNPredictor
- type Predictor
- type Square
- func (s *Square) Area() int
- func (s *Square) AverageDistanceTo(s2 *Square) float64
- func (s *Square) AverageHorizontalDistanceTo(s2 *Square) float64
- func (s *Square) AverageVerticalDistanceTo(s2 *Square) float64
- func (s *Square) DistancesTo(s2 *Square) []float64
- func (s *Square) Expand(c *Coordinate)
- func (s *Square) FarthestDistanceTo(s2 *Square) float64
- func (s *Square) FarthestHorizontalDistanceTo(s2 *Square) float64
- func (s *Square) FarthestVerticalDistanceTo(s2 *Square) float64
- func (s *Square) Height() int
- func (s *Square) HorizontalDistancesTo(s2 *Square) []float64
- func (s *Square) Include(r, c int) bool
- func (s *Square) Merge(a2 *Square)
- func (s *Square) NearestDistanceTo(s2 *Square) float64
- func (s *Square) NearestHorizontalDistanceTo(s2 *Square) float64
- func (s *Square) NearestVerticalDistanceTo(s2 *Square) float64
- func (s *Square) VerticalDistancesTo(s2 *Square) []float64
- func (s *Square) Width() int
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CirucularScan ¶
func CirucularScan(image ImageMatrix) ([][]*Square, [][]ImageMatrix)
func EuclideanDistance ¶
func EuclideanDistance(m1, m2 ImageMatrix) float64
Find the distance of 2 give Dense using Euclidean Distance
func ImageMatrixToImage ¶
func ImageMatrixToImage(imageArray ImageMatrix, outPath string, mul int) error
Convert ImageMatrix to Image and save it to given path
func LinearScan ¶
func LinearScan(data ImageMatrix) [][]ImageMatrix
Scan the DarkSquare and return it as []mat64.Dense for each line And [][]mat64.Dense for each characther
func Prepare ¶
Download the dataset from here and save it in chars74k_dataset/EnglishFnt Also copy index.csv to extracted folder in targetPath
Types ¶
type CNNPredictor ¶
type CNNPredictor struct { InputHeight int InputWidth int // contains filtered or unexported fields }
func NewCNNPredictor ¶
func NewCNNPredictor(graph *tf.Graph, labels []string) *CNNPredictor
func NewCNNPredictorFromDir ¶
func NewCNNPredictorFromDir(dir string) *CNNPredictor
func (*CNNPredictor) Predicts ¶
func (p *CNNPredictor) Predicts(images ImageMatrixs) []string
type Coordinate ¶
type Coordinate struct {
// contains filtered or unexported fields
}
func NewCoordinate ¶
func NewCoordinate(r, c int) *Coordinate
func (*Coordinate) DistanceTo ¶
func (c *Coordinate) DistanceTo(c2 *Coordinate) float64
func (*Coordinate) E ¶
func (c *Coordinate) E() *Coordinate
func (*Coordinate) HorizontalDistanceTo ¶
func (c *Coordinate) HorizontalDistanceTo(c2 *Coordinate) float64
func (*Coordinate) IsInside ¶
func (c *Coordinate) IsInside(s *Square) bool
func (*Coordinate) N ¶
func (c *Coordinate) N() *Coordinate
func (*Coordinate) NE ¶
func (c *Coordinate) NE() *Coordinate
func (*Coordinate) NW ¶
func (c *Coordinate) NW() *Coordinate
func (*Coordinate) S ¶
func (c *Coordinate) S() *Coordinate
func (*Coordinate) SE ¶
func (c *Coordinate) SE() *Coordinate
func (*Coordinate) SW ¶
func (c *Coordinate) SW() *Coordinate
func (*Coordinate) VerticalDistanceTo ¶
func (c *Coordinate) VerticalDistanceTo(c2 *Coordinate) float64
func (*Coordinate) W ¶
func (c *Coordinate) W() *Coordinate
type ImageMatrix ¶
type ImageMatrix [][]uint8
func AdaptiveThres ¶
func AdaptiveThres(im ImageMatrix, bs int) ImageMatrix
func ImageToGraysclaeArray ¶
func ImageToGraysclaeArray(src image.Image) ImageMatrix
Convert image to grayscale 2D array
func NewImageMatrix ¶
func NewImageMatrix(r, c int) ImageMatrix
func NewImageMatrixWithDefaultValue ¶
func NewImageMatrixWithDefaultValue(r, c int, v uint8) ImageMatrix
func PadAndResize ¶
func PadAndResize(matrix ImageMatrix, dr, dc int) ImageMatrix
Adding pad to make a square matrix Then resize it to given row length and column length
func SauvolaBinarization ¶
func SauvolaBinarization(imageArr ImageMatrix) ImageMatrix
Binarize the given imageArr using Best algorithm based on this paper https://pdfs.semanticscholar.org/6347/5461213fdaa24e418c33454c72bdbbe8f8b4.pdf is Sauvola Sauvola Reference: http://www.mediateam.oulu.fi/publications/pdf/24.p TODO: Implement Sauvola algorithm
func (ImageMatrix) At ¶
func (i ImageMatrix) At(r, c int) uint8
func (ImageMatrix) AtCoordinate ¶
func (i ImageMatrix) AtCoordinate(c *Coordinate) uint8
func (ImageMatrix) Col ¶
func (i ImageMatrix) Col(c int) ImageVector
func (ImageMatrix) Dims ¶
func (i ImageMatrix) Dims() (int, int)
func (ImageMatrix) Historgram ¶
func (im ImageMatrix) Historgram() []int
func (ImageMatrix) NNInterpolation ¶
func (i ImageMatrix) NNInterpolation(tr, tc int) ImageMatrix
func (ImageMatrix) Pad ¶
func (i ImageMatrix) Pad(top, bottom, left, right int, value uint8) ImageMatrix
func (ImageMatrix) Row ¶
func (i ImageMatrix) Row(r int) ImageVector
func (ImageMatrix) Set ¶
func (i ImageMatrix) Set(r, c int, value uint8)
func (ImageMatrix) SetSquare ¶
func (im ImageMatrix) SetSquare(s *Square, si ImageMatrix)
func (ImageMatrix) Slice ¶
func (i ImageMatrix) Slice(sr, er, sc, ec int) ImageMatrix
func (ImageMatrix) SliceSquare ¶
func (im ImageMatrix) SliceSquare(s *Square) ImageMatrix
type ImageMatrixs ¶
type ImageMatrixs []ImageMatrix
func (ImageMatrixs) Average ¶
func (is ImageMatrixs) Average() ImageMatrix
type ImageVector ¶
type ImageVector []uint8
func NewImageVector ¶
func NewImageVector(l int) ImageVector
func (ImageVector) Sum ¶
func (v ImageVector) Sum() uint64
type Marker ¶
func MarkersOfMatrix ¶
func MarkersOfMatrix(data ImageMatrix, threshold float64, direction int) []Marker
Find Marker of DarkSquare from given Matrix Direction 0 means it will iterate every rows Direction 1 means it will iterate every columns
type Model ¶
type Model struct { Name string ModelImages []ModelImage }
type ModelImage ¶
type ModelImage struct { Label string Data ImageMatrix }
type NNPredictor ¶
type NNPredictor struct {
// contains filtered or unexported fields
}
================================= Nearest Neighbor Predictor =================================
func NewNNPredictor ¶
func NewNNPredictor(model *Model) *NNPredictor
func NewNNPredictorFromFile ¶
func NewNNPredictorFromFile(path string) *NNPredictor
func (*NNPredictor) Predicts ¶
func (p *NNPredictor) Predicts(images ImageMatrixs) []string
type Predictor ¶
type Predictor interface { Predicts(ImageMatrixs) []string // contains filtered or unexported methods }
type Square ¶
type Square struct {
// contains filtered or unexported fields
}
func NewSquare ¶
func NewSquare(coor1, coor2 *Coordinate) *Square
func (*Square) AverageDistanceTo ¶
func (*Square) AverageHorizontalDistanceTo ¶
func (*Square) AverageVerticalDistanceTo ¶
func (*Square) DistancesTo ¶
func (*Square) Expand ¶
func (s *Square) Expand(c *Coordinate)