本文整理匯總了Golang中captcha/cv.BinaryImage類的典型用法代碼示例。如果您正苦於以下問題:Golang BinaryImage類的具體用法?Golang BinaryImage怎麽用?Golang BinaryImage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了BinaryImage類的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: XHis
func (self *FastCutBasedPredictor) XHis(img *cv.BinaryImage) []int {
h := []int{}
for x := 0; x < img.Width; x++ {
h = append(h, 0)
for y := 0; y < img.Height; y++ {
h[x] += img.Get(x, y)
}
}
return h
}
示例2: FindBeginPos
func FindBeginPos(img *cv.BinaryImage, beginX int) (int, int) {
for x := beginX; x < img.Width; x++ {
for y := 0; y < img.Height; y++ {
if img.IsOpen(x, y) {
return x, y
}
}
}
return img.Width - 1, img.Height - 1
}
示例3: FindEndPos
func FindEndPos(img *cv.BinaryImage, beginX int) int {
for x := beginX; x < img.Width; x++ {
sum := 0
for y := 0; y < img.Height; y++ {
sum += img.Get(x, y)
}
if sum == 0 {
return x
}
}
return img.Width
}
示例4: Match
func (self *Mask) Match(src *cv.BinaryImage, srcLeft int, srcTop int) float64 {
ret := 0.0
for x := srcLeft; x < srcLeft+self.Img.Width && x < src.Width; x++ {
for y := srcTop; y < srcTop+self.Img.Height && y < src.Height; y++ {
if src.IsOpen(x, y) && self.Img.IsOpen(x-srcLeft, y-srcTop) {
ret += 1.0
}
}
}
ret *= 2.0
ret /= float64(self.Img.FrontSize() + src.FrontSize() + 1)
return ret
}
示例5: CutMatrixByRect
func (self *FastCutBasedPredictor) CutMatrixByRect(img *cv.BinaryImage, left, top, right, bottom int) *cv.BinaryImage {
if right <= left || bottom <= top {
return nil
}
ret := cv.NewBinaryImage(right-left, bottom-top)
for x := left; x < right && x < img.Width; x++ {
for y := top; y < bottom && y < img.Height; y++ {
if img.IsOpen(x, y) {
ret.Open(x-left, y-top)
}
}
}
return ret
}
示例6: FindBestMatchedMasks
func (self *MaskIndex) FindBestMatchedMasks(img *cv.BinaryImage, chType int, widthWeight int) []*Result {
h := img.FeatureEncode()
ids, ok := self.index[h]
if !ok {
return nil
}
results := ResultSorter{}
for _, i := range ids {
mk := self.masks[i]
if !mk.MatchChType(chType) {
continue
}
sim := mk.Match(img, 0, 0)
sim *= float64(img.Width)
sim /= float64(img.Width + widthWeight)
results = append(results, NewResult(mk.Label, sim))
}
sort.Sort(results)
return results
}
示例7: QueryMask
func (self *MaskIndex) QueryMask(img *cv.BinaryImage) ([]int, bool) {
h := img.FeatureEncode()
ret, ok := self.index[h]
return ret, ok
}