Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
24
Task/Bitmap-Histogram/Go/bitmap-histogram-1.go
Normal file
24
Task/Bitmap-Histogram/Go/bitmap-histogram-1.go
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
package raster
|
||||
|
||||
import "math"
|
||||
|
||||
func (g *Grmap) Histogram(bins int) []int {
|
||||
if bins <= 0 {
|
||||
bins = g.cols
|
||||
}
|
||||
h := make([]int, bins)
|
||||
for _, p := range g.px {
|
||||
h[int(p)*(bins-1)/math.MaxUint16]++
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
func (g *Grmap) Threshold(t uint16) {
|
||||
for i, p := range g.px {
|
||||
if p < t {
|
||||
g.px[i] = 0
|
||||
} else {
|
||||
g.px[i] = math.MaxUint16
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue