Files
sjy01-image-proc/pkg/producer/grid_img.go
2024-09-04 10:43:20 +08:00

42 lines
770 B
Go

package producer
type GridPoint struct {
Row, Col, H int
}
// 网格点要覆盖边界,甚至大于边界
func gridImage2(m, n, height, width, k, hmin, hmax int) []*GridPoint {
a := int((height) / (m))
var lines []int
for i := 0; i <= m; i++ {
lines = append(lines, a*i)
}
b := int((width) / (n))
var samples []int
for i := 0; i <= n; i++ {
samples = append(samples, b*i)
}
hmax = hmax + 500
hmin = hmin - 500
dh := (hmax - hmin) / (k)
var h []int
for i := 0; i <= k; i++ {
h = append(h, hmin+dh*i)
}
var points []*GridPoint
for i := 0; i < len(lines); i++ {
for j := 0; j < len(samples); j++ {
for l := 0; l < len(h); l++ {
p := GridPoint{lines[i], samples[j], h[l]}
points = append(points, &p)
}
}
}
return points
}