Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions global_histogram_binarizer.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package gozxing

import "sync"

const (
LUMINANCE_BITS = 5
LUMINANCE_SHIFT = 8 - LUMINANCE_BITS
LUMINANCE_BUCKETS = 1 << LUMINANCE_BITS
)

type GlobalHistogramBinarizer struct {
mu sync.Mutex
source LuminanceSource
luminances []byte
buckets []int
Expand All @@ -33,6 +36,9 @@ func (this *GlobalHistogramBinarizer) GetHeight() int {
}

func (this *GlobalHistogramBinarizer) GetBlackRow(y int, row *BitArray) (*BitArray, error) {
this.mu.Lock()
defer this.mu.Unlock()

source := this.GetLuminanceSource()
width := source.GetWidth()
if row == nil || row.GetSize() < width {
Expand Down Expand Up @@ -79,6 +85,9 @@ func (this *GlobalHistogramBinarizer) GetBlackRow(y int, row *BitArray) (*BitArr
}

func (this *GlobalHistogramBinarizer) GetBlackMatrix() (*BitMatrix, error) {
this.mu.Lock()
defer this.mu.Unlock()

source := this.GetLuminanceSource()
width := source.GetWidth()
height := source.GetHeight()
Expand Down
Loading