Documentation ¶
Overview ¶
Package bitmap contains the bitmap data container for the binary images used when decoding the jbig2 encoded images. This package contains also multiple binary image operational functions that classifies them, does the morphology changes, does raster operations and combines multiple instances into single image.
Index ¶
- func Blit(src *Bitmap, dst *Bitmap, x, y int, op CombinationOperator) error
- func ClipBoxToRectangle(box *image.Rectangle, wi, hi int) (out *image.Rectangle, err error)
- func CombineBytes(oldByte, newByte byte, op CombinationOperator) byte
- func CorrelationScore(bm1, bm2 *Bitmap, area1, area2 int, delX, delY float32, maxDiffW, maxDiffH int, ...) (score float64, err error)
- func CorrelationScoreSimple(bm1, bm2 *Bitmap, area1, area2 int, delX, delY float32, maxDiffW, maxDiffH int, ...) (score float64, err error)
- func CorrelationScoreThresholded(bm1, bm2 *Bitmap, area1, area2 int, delX, delY float32, maxDiffW, maxDiffH int, ...) (bool, error)
- func HausTest(p1, p2, p3, p4 *Bitmap, delX, delY float32, maxDiffW, maxDiffH int) (bool, error)
- func MakePixelCentroidTab8() []int
- func MakePixelSumTab8() []int
- func RankHausTest(p1, p2, p3, p4 *Bitmap, delX, delY float32, ...) (match bool, err error)
- func RasterOperation(dest *Bitmap, dx, dy, dw, dh int, op RasterOperator, src *Bitmap, sx, sy int) error
- func Rect(x, y, w, h int) (*image.Rectangle, error)
- func TstAddSymbol(t *testing.T, bms *Bitmaps, sym *Bitmap, x *int, y int, space int)
- func TstFrameBitmapData() []byte
- func TstImageBitmapData() []byte
- func TstWriteSymbols(t *testing.T, bms *Bitmaps, src *Bitmap)
- type Bitmap
- func Copy(d, s *Bitmap) (*Bitmap, error)
- func Dilate(d *Bitmap, s *Bitmap, sel *Selection) (*Bitmap, error)
- func DilateBrick(d, s *Bitmap, hSize, vSize int) (*Bitmap, error)
- func Extract(roi image.Rectangle, src *Bitmap) (*Bitmap, error)
- func MorphSequence(src *Bitmap, sequence ...MorphProcess) (*Bitmap, error)
- func New(width, height int) *Bitmap
- func NewWithData(width, height int, data []byte) (*Bitmap, error)
- func NewWithUnpaddedData(width, height int, data []byte) (*Bitmap, error)
- func TstASymbol(t *testing.T) *Bitmap
- func TstCSymbol(t *testing.T) *Bitmap
- func TstDSymbol(t *testing.T, scale ...int) *Bitmap
- func TstESymbol(t *testing.T, scale ...int) *Bitmap
- func TstFrameBitmap() *Bitmap
- func TstGetScaledSymbol(t *testing.T, sm *Bitmap, scale ...int) *Bitmap
- func TstISymbol(t *testing.T, scale ...int) *Bitmap
- func TstImageBitmap() *Bitmap
- func TstNSymbol(t *testing.T, scale ...int) *Bitmap
- func TstOSymbol(t *testing.T, scale ...int) *Bitmap
- func TstPSymbol(t *testing.T) *Bitmap
- func TstRSymbol(t *testing.T, scale ...int) *Bitmap
- func TstTSymbol(t *testing.T, scale ...int) *Bitmap
- func TstVSymbol(t *testing.T, scale ...int) *Bitmap
- func TstWSymbol(t *testing.T, scale ...int) *Bitmap
- func TstWordBitmap(t *testing.T, scale ...int) *Bitmap
- func TstWordBitmapWithSpaces(t *testing.T, scale ...int) *Bitmap
- func (b *Bitmap) AddBorder(borderSize, val int) (*Bitmap, error)
- func (b *Bitmap) AddBorderGeneral(left, right, top, bot int, val int) (*Bitmap, error)
- func (b *Bitmap) And(s *Bitmap) (d *Bitmap, err error)
- func (b *Bitmap) ClipRectangle(box *image.Rectangle) (d *Bitmap, boxC *image.Rectangle, err error)
- func (b *Bitmap) ConnComponents(bms *Bitmaps, connectivity int) (boxa *Boxes, err error)
- func (b *Bitmap) Copy() *Bitmap
- func (b *Bitmap) CountPixels() int
- func (b *Bitmap) CreateTemplate() *Bitmap
- func (b *Bitmap) Equals(s *Bitmap) bool
- func (b *Bitmap) Equivalent(s *Bitmap) bool
- func (b *Bitmap) GetBitOffset(x int) int
- func (b *Bitmap) GetByte(index int) (byte, error)
- func (b *Bitmap) GetByteIndex(x, y int) int
- func (b *Bitmap) GetChocolateData() []byte
- func (b *Bitmap) GetComponents(components Component, maxWidth, maxHeight int) (bitmaps *Bitmaps, boxes *Boxes, err error)
- func (b *Bitmap) GetPixel(x, y int) bool
- func (b *Bitmap) GetUnpaddedData() ([]byte, error)
- func (b *Bitmap) GetVanillaData() []byte
- func (b *Bitmap) InverseData()
- func (b *Bitmap) RasterOperation(dx, dy, dw, dh int, op RasterOperator, src *Bitmap, sx, sy int) error
- func (b *Bitmap) RemoveBorder(borderSize int) (*Bitmap, error)
- func (b *Bitmap) RemoveBorderGeneral(left, right, top, bot int) (*Bitmap, error)
- func (b *Bitmap) SetByte(index int, v byte) error
- func (b *Bitmap) SetDefaultPixel()
- func (b *Bitmap) SetPadBits(value int)
- func (b *Bitmap) SetPixel(x, y int, pixel byte) error
- func (b *Bitmap) SizesEqual(s *Bitmap) bool
- func (b *Bitmap) String() string
- func (b *Bitmap) ThresholdPixelSum(thresh int, tab8 []int) (above bool, err error)
- func (b *Bitmap) ToImage() image.Image
- func (b *Bitmap) Zero() bool
- type Bitmaps
- func (b *Bitmaps) AddBitmap(bm *Bitmap)
- func (b *Bitmaps) AddBox(box *image.Rectangle)
- func (b *Bitmaps) ClipToBitmap(s *Bitmap) (*Bitmaps, error)
- func (b *Bitmaps) CountPixels() *basic.NumSlice
- func (b *Bitmaps) GetBitmap(i int) (*Bitmap, error)
- func (b *Bitmaps) GetBox(i int) (*image.Rectangle, error)
- func (b *Bitmaps) GroupByHeight() (*BitmapsArray, error)
- func (b *Bitmaps) GroupByWidth() (*BitmapsArray, error)
- func (b *Bitmaps) HeightSorter() func(i, j int) bool
- func (b *Bitmaps) SelectByIndexes(idx []int) (*Bitmaps, error)
- func (b *Bitmaps) SelectBySize(width, height int, tp LocationFilter, relation SizeComparison) (d *Bitmaps, err error)
- func (b *Bitmaps) Size() int
- func (b *Bitmaps) SortByHeight()
- func (b *Bitmaps) SortByWidth()
- func (b *Bitmaps) String() string
- func (b *Bitmaps) WidthSorter() func(i, j int) bool
- type BitmapsArray
- type BoundaryCondition
- type Boxes
- type ClassedPoints
- func (c *ClassedPoints) GetIntXByClass(i int) (int, error)
- func (c *ClassedPoints) GetIntYByClass(i int) (int, error)
- func (c *ClassedPoints) GroupByY() ([]*ClassedPoints, error)
- func (c *ClassedPoints) Len() int
- func (c *ClassedPoints) Less(i, j int) bool
- func (c *ClassedPoints) SortByX()
- func (c *ClassedPoints) SortByY()
- func (c *ClassedPoints) Swap(i, j int)
- func (c *ClassedPoints) XAtIndex(i int) float32
- func (c *ClassedPoints) YAtIndex(i int) float32
- type Color
- type CombinationOperator
- type Component
- type Getter
- type LocationFilter
- type MorphOperation
- type MorphProcess
- type Point
- type Points
- func (p *Points) Add(pt *Points) error
- func (p *Points) AddPoint(x, y float32)
- func (p Points) Get(i int) (Point, error)
- func (p Points) GetGeometry(i int) (x, y float32, err error)
- func (p Points) GetIntX(i int) (int, error)
- func (p Points) GetIntY(i int) (int, error)
- func (p Points) Size() int
- func (p Points) XSorter() func(i, j int) bool
- func (p Points) YSorter() func(i, j int) bool
- type RasterOperator
- type Selection
- type SelectionValue
- type SizeComparison
- type SizeSelection
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Blit ¶
func Blit(src *Bitmap, dst *Bitmap, x, y int, op CombinationOperator) error
Blit blits the source Bitmap 'src' into Destination bitmap: 'dst' on the provided 'x' and 'y' coordinates with respect to the combination operator 'op'.
func ClipBoxToRectangle ¶
ClipBoxToRectangle clips the image.Rectangle 'box' for the provided wi, hi which are rectangle representing image. The UL corner of the 'box' is assumed to be at (0,0) and LR at ('wi' - 1, 'hi' - 1)
func CombineBytes ¶
func CombineBytes(oldByte, newByte byte, op CombinationOperator) byte
CombineBytes combines the provided bytes with respect to the CombinationOperator.
func CorrelationScore ¶
func CorrelationScore(bm1, bm2 *Bitmap, area1, area2 int, delX, delY float32, maxDiffW, maxDiffH int, tab []int) (score float64, err error)
CorrelationScore computes the correlation score between the bitmaps: 'bm1' and 'bm2'. The correlation score is the ratio of the square of the number of pixels AND of the two bitmaps to the product of the number of ON pixels in each.
func CorrelationScoreSimple ¶
func CorrelationScoreSimple(bm1, bm2 *Bitmap, area1, area2 int, delX, delY float32, maxDiffW, maxDiffH int, tab []int) (score float64, err error)
CorrelationScoreSimple computes the correlation score value which should be the same as the result of the 'CorrelationScore' function. This function uses raster operations and is about 2-3x slower. This function makes it easier to understand how is the correlation computed.
func CorrelationScoreThresholded ¶
func CorrelationScoreThresholded(bm1, bm2 *Bitmap, area1, area2 int, delX, delY float32, maxDiffW, maxDiffH int, tab, downcount []int, scoreThreshold float32) (bool, error)
CorrelationScoreThresholded checks whether the correlation score is >= scoreThreshold. 'area1' - number of 'ON' pixels in 'bm1'. 'area2' - number of 'ON' pixels in 'bm2'. 'delX' - x comp of centroid difference. 'delY' - y comp of centroid difference. 'maxDiffW' - max width difference between 'bm1' and 'bm2'. 'maxDiffH' - max height difference between 'bm1' and 'bm2'. 'tab' - is a sum tab for the and byte (created by MakeSumTab8 function). 'downcount' - is the number of 'ON' pixels below each row of bitmap 'bm1'. 'score_threshold' - is the correlation score that the bitmaps should have at least to return false.
func HausTest ¶
HausTest does the Hausdorff 2-way check for the provided bitmaps. Parameters:
p1 - new not dilated bitmap p2 - new dilated bitmap p3 - exemplar not dilated bitmap p4 - exemplar dilated bitmap delX, delY - component centroid difference for 'x' and 'y' coordinates. maxDiffW - maximum width difference of 'p1' and 'p2' maxDiffH - maximum height difference of 'p1' and 'p2'
The centroid difference is used to align two images to the nearest integer for each check. It checks if the dilated image of one contains all the pixels of the undilated image of the other.
func MakePixelCentroidTab8 ¶
func MakePixelCentroidTab8() []int
MakePixelCentroidTab8 creates table of integers gives the centroid weight of the 1 bits in the 8 bit index.
func MakePixelSumTab8 ¶
func MakePixelSumTab8() []int
MakePixelSumTab8 creates table of integers that gives the number of 1 bits in the 8 bit index.
func RankHausTest ¶
func RankHausTest(p1, p2, p3, p4 *Bitmap, delX, delY float32, maxDiffW, maxDiffH, area1, area3 int, rank float32, tab8 []int) (match bool, err error)
RankHausTest does the test of the Hausdorff ranked check. Parameters:
p1 - new bitmap, not dilated p2 - new bitmap, dilated p3 -u exemplar bitmap, not dilated p4 - exemplar bitmap, dilated delX, delY - component centroid difference for 'x' and 'y' coordinates maxDiffW - maximum Width difference of 'p1' and 'p2' maxDiffH - maximum Height difference of 'p1' and 'p2' area1 - 'ON' - fg - pixels area of the 'p1' bitmap area3 - 'ON' - fg - pixels area of the 'p3' bitmap rank - rank value of the test tab8 - table of the pixel sums for a single byte.
The 'rank' value is being converted to a number of pixels by multiplication with the number of undilated images. The centroid difference is used for alignment of the images. The rank Hausdorff checks if dilated image of one contains the rank fraction pixels of the undilated image of the other in both directions.
func RasterOperation ¶
func RasterOperation(dest *Bitmap, dx, dy, dw, dh int, op RasterOperator, src *Bitmap, sx, sy int) error
RasterOperation does the rastering operation on the provided 'dest' bitmap. There are 18 operations, described by the 'op' RasterOperator. The PixDst is a no-op.
PixClr, PixSet, PixNotPixDst operate only on the 'dest'.
The other 14 involve both 'src' and 'dest' bitmaps and depends on the bit values of either just the src or the both 'src' and 'dest'. Out of these 14 operators there are only 12 unique logical combinations. ~(s) ^ d) == ~(s ^ d) == s ^ ~(d). Parameters:
'dest' 'dest' bitmap 'dx' x val of UL corner of 'dest' bitmap 'dy' y val of UL corner of 'dest' bitmap 'dw' is the width of the operational rectangle on the bitmap 'dest' 'dh' is the height of the operational rectangle on the bitmap 'dest' 'op' raster operator code 'src' 'src' bitmap 'sx' x val of UL corner of 'src' bitmap 'sy' y val of UL corner of 'src' bitmap
func TstAddSymbol ¶
TstAddSymbol is a helper function that adds 'sym' at the 'x' and 'y' position.
func TstFrameBitmapData ¶
func TstFrameBitmapData() []byte
TstFrameBitmapData gets the test frame bitmap data
func TstImageBitmapData ¶
func TstImageBitmapData() []byte
TstImageBitmapData gets the test image bitmap data
Types ¶
type Bitmap ¶
type Bitmap struct {
// Width and Height represents bitmap dimensions.
Width, Height int
// BitmapNumber is the bitmap's id number.
BitmapNumber int
// RowStride is the number of bytes set per row.
RowStride int
// Data saves the bits data for the bitmap.
Data []byte
// Color is the bitmap's color interpretation.
Color Color
// Special instructions for I/O.
Special int
// Text string associated with the pix.
Text string
// The XResolution and YResolution are the
// image resolution parameters at width and height.
XResolution, YResolution int
}
Bitmap is the jbig2 bitmap representation.
func Dilate ¶
Dilate the source bitmap 's' using hits in the selection 'sel'. The 'd' destination bitmap is optional. The following cases are possible:
'd' == 's' the function writes the result back to 'src'. 'd' == nil the function creates new bitmap and writes the result to it. 'd' != 's' puts the results into existing 'd'.
func DilateBrick ¶
DilateBrick dilate with all sel being hit.
func MorphSequence ¶
func MorphSequence(src *Bitmap, sequence ...MorphProcess) (*Bitmap, error)
MorphSequence does the morph processes over the 'src' Bitmap with the provided sequence.
func NewWithData ¶
NewWithData creates new bitmap with the provided 'width', 'height' and the byte slice 'data'.
func NewWithUnpaddedData ¶
NewWithUnpaddedData creates new bitmap with provided 'width', 'height' and the byte slice 'data' that doesn't contains paddings on the last byte of each row. This function adds the padding to the bitmap data.
func TstASymbol ¶
TstASymbol is a helper function to get 'A' symbol.
func TstCSymbol ¶
TstCSymbol is a helper function to get 'C' symbol.
func TstDSymbol ¶
TstDSymbol is a helper function to get 'D' symbol.
func TstESymbol ¶
TstESymbol is a helper function to write 'E' letter.
func TstGetScaledSymbol ¶
TstGetScaledSymbol is a helper function to get scaled bitmap.
func TstISymbol ¶
TstISymbol is a helper function to get 'I' symbol.
func TstNSymbol ¶
TstNSymbol is a helper function to write 'N' letter.
func TstOSymbol ¶
TstOSymbol is a helper function to get 'O' symbol.
func TstPSymbol ¶
TstPSymbol is a helper function to get 'P' symbol.
func TstRSymbol ¶
TstRSymbol is a helper function to write 'R' letter.
func TstTSymbol ¶
TstTSymbol is a helper function to write 'T' letter
func TstVSymbol ¶
TstVSymbol is a helper function to get 'V' symbol.
func TstWSymbol ¶
TstWSymbol is a helper function to write 'W' letter.
func TstWordBitmap ¶
TstWordBitmap creates a bitmap with the words like: DO IT NOW OR NEVER without any boundaries.
func TstWordBitmapWithSpaces ¶
TstWordBitmapWithSpaces gets no space from the top, bottom, left and right edge.
func (*Bitmap) AddBorder ¶
AddBorder creates a new bitmap with the border of size 'borderSize'. If the 'borderSize' is different than zero the resultant bitmap dimensions would increase by width += 2* borderSize, height += 2*borderSize. The value 'val' represents the binary bit 'value' of the border - '0' and '1'
func (*Bitmap) AddBorderGeneral ¶
AddBorderGeneral creates new bitmap on the base of the bitmap 'b' with the border of size for each side 'left','right','top','bot'. The 'val' sets the border white (0) or black (1).
func (*Bitmap) ClipRectangle ¶
ClipRectangle clips the 'b' Bitmap to the 'box' with relatively defined coordinates. If the box is not contained within the pix the 'box' is clipped to the 'b' size.
func (*Bitmap) ConnComponents ¶
ConnComponents is a top level call for decomposing the bitmap 'b' by creating components. Each component is a part of bitmap where each pixel is connected with at least one neighbor. The 'connectivity' is the number of possible directions where the pixel neighbors could be found. The only possible values it could take is 4 and 8. The connectivity 4 checks the neighbors at top, bottom, left and right, where connectivity 8 checks also upper left, upper right, bottom left and bottom right. The 'bms' is an optional argument. If it's not nil the components created by the function are added to the 'bms' Bitmaps. It sets up 2 temporary bitmaps and for each connected components that is located in raster order, it erase the c.c from one bitmap then uses the bounding box to extract component from the 'two' bitmap using XOR operation, and finally erase the component from the second bm. Returns bounding boxes of the components. If the bitmaps 'bms' are provided the boxes are added to it's Boxes variable.
func (*Bitmap) CountPixels ¶
CountPixels counts the pixels for the bitmap 'b'.
func (*Bitmap) CreateTemplate ¶
CreateTemplate creates a copy template bitmap on the base of the bitmap 'b'. A template has the same parameters as bitmap 'b', but contains empty Data.
func (*Bitmap) Equals ¶
Equals checks if all the pixels in the 'b' bitmap are equals to the 's' bitmap.
func (*Bitmap) Equivalent ¶
Equivalent checks if the bitmaps 'b' and 's' are equivalent from the visual point of view.
func (*Bitmap) GetBitOffset ¶
GetBitOffset gets the bit offset at the 'x' coordinate.
func (*Bitmap) GetByteIndex ¶
GetByteIndex gets the byte index from the bitmap at coordinates 'x','y'.
func (*Bitmap) GetChocolateData ¶
GetChocolateData gets bitmap data as a byte slice with Chocolate bit interpretation. 'Chocolate' data is the bit interpretation where the 0'th bit means white and the 1'th bit means black. The naming convention based on the: `https://en.wikipedia.org/wiki/Binary_image#Interpretation` page.
func (*Bitmap) GetComponents ¶
func (b *Bitmap) GetComponents(components Component, maxWidth, maxHeight int) (bitmaps *Bitmaps, boxes *Boxes, err error)
GetComponents determine the bitmap 'b' image components.
func (*Bitmap) GetUnpaddedData ¶
GetUnpaddedData gets the data without row stride padding. The unpadded data contains bitmap.Height * bitmap.Width bits with optional last byte padding.
func (*Bitmap) GetVanillaData ¶
GetVanillaData gets bitmap data as a byte slice with Vanilla bit interpretation. 'Vanilla' is the bit interpretation where the 0'th bit means black and 1'th bit means white. The naming convention based on the `https://en.wikipedia.org/wiki/Binary_image#Interpretation` page.
func (*Bitmap) InverseData ¶
func (b *Bitmap) InverseData()
InverseData inverses the data color interpretation.
func (*Bitmap) RasterOperation ¶
func (b *Bitmap) RasterOperation(dx, dy, dw, dh int, op RasterOperator, src *Bitmap, sx, sy int) error
RasterOperation has the same function as the RasterOperation package function, where the 'b' bitmap is the 'dest'.
func (*Bitmap) RemoveBorder ¶
RemoveBorder create a new bitmap based on the 'b' with removed border of size 'borderSize'.
func (*Bitmap) RemoveBorderGeneral ¶
RemoveBorderGeneral creates a new bitmap with removed border of size 'left', 'right', 'top', 'bot'. The resultant bitmap dimensions would be smaller by the value of border size.
func (*Bitmap) SetByte ¶
SetByte sets the byte at 'index' with value 'v'. Returns an error if the index is out of range.
func (*Bitmap) SetDefaultPixel ¶
func (b *Bitmap) SetDefaultPixel()
SetDefaultPixel sets all bits within bitmap to '1'.
func (*Bitmap) SetPadBits ¶
SetPadBits sets the pad bits for the current bitmap.
func (*Bitmap) SetPixel ¶
SetPixel sets the pixel at 'x', 'y' coordinates with the value of 'pixel'. Returns an error if the index is out of range.
func (*Bitmap) SizesEqual ¶
SizesEqual checks if the bitmaps are of the same size.
func (*Bitmap) ThresholdPixelSum ¶
ThresholdPixelSum checks if the number of the 'ON' pixels is above the provided 'thresh' threshold. If the on pixel count > thresh the function returns quckly.
type Bitmaps ¶
Bitmaps is the structure that contains slice of the bitmaps and the bounding boxes. It allows to safely get the Bitmap and the bounding boxes.
func (*Bitmaps) ClipToBitmap ¶
ClipToBitmap returns a Bitmaps where each Bitmap is 'AND'ed with with the associated region stored in box with the 's' Bitmap.
func (*Bitmaps) CountPixels ¶
CountPixels counts the pixels for all the bitmaps and stores into *basic.NumSlice.
func (*Bitmaps) GetBitmap ¶
GetBitmap gets the bitmap at the 'i' index. If the index is out of possible range the function returns error.
func (*Bitmaps) GetBox ¶
GetBox gets the Box at the 'i' index. If the index is out of range the function returns error.
func (*Bitmaps) GroupByHeight ¶
func (b *Bitmaps) GroupByHeight() (*BitmapsArray, error)
GroupByHeight groups bitmaps by height sorted from the lowest to the highest.
func (*Bitmaps) GroupByWidth ¶
func (b *Bitmaps) GroupByWidth() (*BitmapsArray, error)
GroupByWidth groups bitmaps by height sorted from the lowest to the highest.
func (*Bitmaps) HeightSorter ¶
HeightSorter returns sorting function based on the bitmaps height.
func (*Bitmaps) SelectByIndexes ¶
SelectByIndexes selects bitmaps by provided indexes 'idx'.
func (*Bitmaps) SelectBySize ¶
func (b *Bitmaps) SelectBySize(width, height int, tp LocationFilter, relation SizeComparison) (d *Bitmaps, err error)
SelectBySize selects provided bitmaps by provided 'width', 'height' location filter 'tp' and size comparison 'relation. Returns 'b' bitmap if it's empty or all the bitmaps matches the pattern.
func (*Bitmaps) SortByHeight ¶
func (b *Bitmaps) SortByHeight()
SortByHeight sorts the bitmaps by height.
func (*Bitmaps) WidthSorter ¶
WidthSorter returns the sorting function based on the bitmaps width.
type BitmapsArray ¶
BitmapsArray is the struct that contains slice of the 'Bitmaps', with the bounding boxes around each 'Bitmaps'.
func (*BitmapsArray) AddBitmaps ¶
func (b *BitmapsArray) AddBitmaps(bm *Bitmaps)
AddBitmaps adds the 'bm' Bitmaps to the 'b'.Values.
func (*BitmapsArray) AddBox ¶
func (b *BitmapsArray) AddBox(box *image.Rectangle)
AddBox adds the 'box' to the 'b' Boxes.
func (*BitmapsArray) GetBitmaps ¶
func (b *BitmapsArray) GetBitmaps(i int) (*Bitmaps, error)
GetBitmaps gets the 'Bitmaps' at the 'i' position. Returns error if the index is out of range.
type BoundaryCondition ¶
type BoundaryCondition int
BoundaryCondition is the global enum variable used to define morph operation boundary conditions. More information about the definition could be found at: http://www.leptonica.org/binary-morphology.html#boundary-conditions
const ( // AsymmetricMorphBC defines the asymmetric boundary condition for morph functions. AsymmetricMorphBC BoundaryCondition = iota // SymmetricMorphBC defines the symmetric boundary condition for morph funcftions. SymmetricMorphBC )
var MorphBC BoundaryCondition
MorphBC defines current morph boundary condition used by the morph functions. By default it is set to 'AsymetricMorphBC'.
type Boxes ¶
Boxes is the wrapper over the slice of image.Rectangles that allows to get and add the image.Rectangle safely.
func (*Boxes) SelectBySize ¶
func (b *Boxes) SelectBySize(width, height int, tp LocationFilter, relation SizeComparison) (result *Boxes, err error)
SelectBySize select sthe boxes 'b' by provided 'width' 'height', location filter 'tp' and 'relation'. If nothing changes the function returns the boxes 'b' by itself.
type ClassedPoints ¶
ClassedPoints is the wrapper that contains both points and integer slice, where each index in point relates to the index of int slice. Even though the type implements sort.Interface, don't use it directly - as this would panic. Use SortByX, or SortByY function.
func NewClassedPoints ¶
func NewClassedPoints(points *Points, classes basic.IntSlice) (*ClassedPoints, error)
NewClassedPoints creates and validates PointsBitmaps based on provided 'points' and 'classes'. The classes contains id's of the classes related to the index of the 'points'.
func (*ClassedPoints) GetIntXByClass ¶
func (c *ClassedPoints) GetIntXByClass(i int) (int, error)
GetIntXByClass gets the integer of point.Y by the index of the 'IntSlice'.
func (*ClassedPoints) GetIntYByClass ¶
func (c *ClassedPoints) GetIntYByClass(i int) (int, error)
GetIntYByClass gets the integer of point.Y by the index of the 'IntSlice'.
func (*ClassedPoints) GroupByY ¶
func (c *ClassedPoints) GroupByY() ([]*ClassedPoints, error)
GroupByY groups provided intSlice into ClassedPoints based on their 'Y'.
func (*ClassedPoints) Len ¶
func (c *ClassedPoints) Len() int
Len implements sort.Interface interface.
func (*ClassedPoints) Less ¶
func (c *ClassedPoints) Less(i, j int) bool
Less implements sort.Interface.
func (*ClassedPoints) SortByX ¶
func (c *ClassedPoints) SortByX()
SortByX sorts classed points by x coordinate.
func (*ClassedPoints) SortByY ¶
func (c *ClassedPoints) SortByY()
SortByY sorts classed points by y coordinate.
func (*ClassedPoints) Swap ¶
func (c *ClassedPoints) Swap(i, j int)
Swap implements sort.Interface interface.
func (*ClassedPoints) XAtIndex ¶
func (c *ClassedPoints) XAtIndex(i int) float32
XAtIndex gets the 'x' coordinate from the points where the 'i' is the index of the IntSlice.
func (*ClassedPoints) YAtIndex ¶
func (c *ClassedPoints) YAtIndex(i int) float32
YAtIndex gets the 'y' coordinate from the points where the 'i' is the index of the IntSlice.
type Color ¶
type Color int
Color is the jbig2 color interpretation enum. The naming convention taken from 'https://en.wikipedia.org/wiki/Binary_image#Interpretation'.
type CombinationOperator ¶
type CombinationOperator int
CombinationOperator is the operator used for combining the bitmaps.
const ( // CmbOpOr is the 'OR' CombinationOperator. CmbOpOr CombinationOperator = iota // CmbOpAnd is the 'AND' CombinationOperator. CmbOpAnd // CmbOpXor is the 'XOR' CombinationOperator. CmbOpXor // CmbOpXNor is the 'XNOR' CombinationOperator. CmbOpXNor // CmbOpReplace is the 'REPLACE' CombinationOperator. CmbOpReplace // CmbOpNot is the 'NOT' CombinationOperator. CmbOpNot )
func (CombinationOperator) String ¶
func (c CombinationOperator) String() string
String implements Stringer interface.
type Getter ¶
type Getter interface {
GetBitmap() *Bitmap
}
Getter interface used for getting the Bitmap.
type LocationFilter ¶
type LocationFilter int
LocationFilter is predefined enum wrapper used for selection of boxes and bitmaps
const ( // LocSelectWidth is the location filter where the width must satisfy constraint. LocSelectWidth LocationFilter // LocSelectHeight is the location filter where the height must satisfy constarint. LocSelectHeight // LocSelectXVal is the location filter where the 'x' value must satisfy constraint. LocSelectXVal // LocSelectYVal is the location filter where the 'y' value must satisfy constraint. LocSelectYVal // LocSelectIfEither is the location filter where either width or height can satisfy constraint. LocSelectIfEither // LocSelectIfBoth is the location filter where both width and height must satisfy constraint. LocSelectIfBoth )
type MorphOperation ¶
type MorphOperation int
MorphOperation is an enum that wraps the morph operations.
const ( MopDilation MorphOperation = iota MopErosion MopOpening MopClosing MopRankBinaryReduction MopReplicativeBinaryExpansion MopAddBorder )
Enum morph operations.
type MorphProcess ¶
type MorphProcess struct { Operation MorphOperation Arguments []int }
MorphProcess is the combination of the morph operator with it's values.
type Point ¶
type Point struct {
X, Y float32
}
Point is the basic structure that contains x, y float32 values. In compare with image.Point the x and y are floats not integers.
type Points ¶
type Points []Point
Points is the slice of the float Points that has panic safe methods for getting and adding new Points.
func Centroids ¶
Centroids gets the centroids relative to the UL corner of each pix for the provided bitmaps.
func (Points) Get ¶
Get gets the point at 'i' index. Returns error if the 'i' index is out of range.
func (Points) GetGeometry ¶
GetGeometry gets the geometry 'x' and 'y' of the point at the 'i' index. Returns error if the index is out of range.
type RasterOperator ¶
type RasterOperator int
RasterOperator is the raster operation flag operator. There are following raster operations:
PixClr 0000 0x0 PixSet 1111 0xf PixSrc s 1100 0xc PixDst d 1010 0xa PixNotSrc ~s 0011 0x3 PixNotDst ~d 0101 0x5 PixSrcOrDst s | d 1110 0xe PixSrcAndDst s & d 1000 0x8 PixSrcXorDst s ^ d 0110 0x6 PixNotSrcOrDst ~s | d 1011 0xb PixNotSrcAndDst ~s & d 0010 0x2 PixSrcOrNotDst s | ~d 1101 0xd PixSrcAndNotDst s & ~d 0100 0x4 PixNotPixSrcOrDst ~(s | d) 0001 0x1 PixNotPixSrcAndDst ~(s & d) 0111 0x7 PixNotPixSrcXorDst ~(s ^ d) 1001 0X9
const ( PixSrc RasterOperator = 0xc PixDst RasterOperator = 0xa PixNotSrc RasterOperator = 0x3 PixNotDst RasterOperator = 0x5 PixClr RasterOperator = 0x0 PixSet RasterOperator = 0xf PixSrcOrDst RasterOperator = 0xe PixSrcAndDst RasterOperator = 0x8 PixSrcXorDst RasterOperator = 0x6 PixNotSrcOrDst RasterOperator = 0xb PixNotSrcAndDst RasterOperator = 0x2 PixSrcOrNotDst RasterOperator = 0xd PixSrcAndNotDst RasterOperator = 0x4 PixNotPixSrcOrDst RasterOperator = 0x1 PixNotPixSrcAndDst RasterOperator = 0x7 PixNotPixSrcXorDst RasterOperator = 0x9 PixPaint = PixSrcOrDst PixSubtract = PixNotSrcAndDst PixMask = PixSrcAndDst )
Raster operator constant definitions.
type Selection ¶
type Selection struct {
Height, Width int
// Location of the Selection origin.
Cx, Cy int
Name string
Data [][]SelectionValue
}
Selection is the structure used for matching the bitmaps.
func SelCreateBrick ¶
func SelCreateBrick(h, w int, cy, cx int, tp SelectionValue) *Selection
SelCreateBrick creates a rectangular selection of all hits, misses or don't cares.
type SelectionValue ¶
type SelectionValue int
SelectionValue is the enum value used for the Selection data.
const ( SelDontCare SelectionValue = iota SelHit SelMiss )
SelectionValue enums values.
type SizeComparison ¶
type SizeComparison int
SizeComparison is the predefined enum wrapper used for size comparison.
const ( // SizeSelectIfLT is the size comparison used to save the value if it's less than threshold. SizeSelectIfLT SizeComparison // SizeSelectIfGT is the size comparison used to save the value if it's more than threshold. SizeSelectIfGT // SizeSelectIfLTE is the size comparison used to save the value if it's less or equal to threshold. SizeSelectIfLTE // SizeSelectIfGTE is the size comparison used to save the value if it's less more or equal to threshold. SizeSelectIfGTE // SizeSelectIfEQ is the size comparison used to save the values if it's equal to threshold. SizeSelectIfEQ )
type SizeSelection ¶
type SizeSelection int
SizeSelection is the predefined enum wrapper used for size selection for boxes and bitmaps.
const ( // SizeSelectByWidth is the size select enum used for selecting by width. SizeSelectByWidth SizeSelection // SizeSelectByHeight is the size select enum used for selecting by height. SizeSelectByHeight // SizeSelectByMaxDimension is the size select enum used for selecting by max of width and height. SizeSelectByMaxDimension // SizeSelectByArea is the size select enum used for selecting by area. SizeSelectByArea // SizeSelectByPerimeter is the size select enum used for selecting by perimeter. SizeSelectByPerimeter )