-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
44 lines (32 loc) · 754 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package main
import (
"fmt"
_ "image/jpeg"
"os"
"time"
)
func pointsToXY(pts []floatPoint) ([]float64, []float64) {
X := []float64{}
Y := []float64{}
for _, pt := range pts {
X = append(X, pt.x)
Y = append(Y, pt.y)
}
return X, Y
}
func main() {
t := time.Now()
var img, err = loadImage("./in/" + os.Args[1])
check(err)
_, rImg := rgbaToGrayArray(img)
kernel := createGaussianKernel(5, 1)
res := conv2d(rImg, kernel)
kx := conv2d(res, scharrKx)
ky := conv2d(res, scharrKy)
sobelMagnitude, sobelSlope := magnitudeOfGradient(kx, ky)
finalMag := arrayToGray(sobelMagnitude)
finalSlope := arrayToGray(sobelSlope)
saveImage("./out/mag.jpg", finalMag)
saveImage("./out/slope.jpg", finalSlope)
fmt.Println(time.Since(t))
}