Skip to content

Commit ee837db

Browse files
committed
Added ThresholdFilter
1 parent 1d591e1 commit ee837db

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

cmd/thresh.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
//go:build ignore
2+
3+
package main
4+
5+
import (
6+
"flag"
7+
"github.com/jphsd/graphics2d/image"
8+
"github.com/jphsd/texture"
9+
)
10+
11+
func main() {
12+
vv := flag.Float64("v", 0, "threshold")
13+
flag.Parse()
14+
v := *vv
15+
name := flag.Args()[0]
16+
17+
img, err := image.ReadImage(name)
18+
if err != nil {
19+
panic(err)
20+
}
21+
22+
width, height := img.Bounds().Dx(), img.Bounds().Dy()
23+
24+
cf := texture.NewImage(img, texture.LinearInterp)
25+
f2 := texture.NewColorToGray(cf)
26+
vf := texture.NewThresholdFilter(f2, v, -1, 1)
27+
img2 := texture.NewTextureGray16(width, height, vf, 0, 0, 1, 1, false)
28+
29+
image.SaveImage(img2, "thresh")
30+
}

0 commit comments

Comments
 (0)