本文整理汇总了Golang中github.com/janelia-flyem/dvid/dvid.Geometry.StartPoint方法的典型用法代码示例。如果您正苦于以下问题:Golang Geometry.StartPoint方法的具体用法?Golang Geometry.StartPoint怎么用?Golang Geometry.StartPoint使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/janelia-flyem/dvid/dvid.Geometry
的用法示例。
在下文中一共展示了Geometry.StartPoint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addLabelZ
// Convert a 32-bit label into a 64-bit label by adding the Z coordinate into high 32 bits.
// Also drops the high byte (alpha channel) since Raveler labels only use 24-bits.
func (d *Data) addLabelZ(geom dvid.Geometry, data32 []uint8, stride int32) ([]byte, error) {
if len(data32)%4 != 0 {
return nil, fmt.Errorf("expected 4 byte/voxel alignment but have %d bytes!", len(data32))
}
coord := geom.StartPoint()
if coord.NumDims() < 3 {
return nil, fmt.Errorf("expected n-d (n >= 3) offset for image. Got %d dimensions.",
coord.NumDims())
}
superpixelBytes := make([]byte, 8, 8)
binary.BigEndian.PutUint32(superpixelBytes[0:4], uint32(coord.Value(2)))
nx := int(geom.Size().Value(0))
ny := int(geom.Size().Value(1))
numBytes := nx * ny * 8
data64 := make([]byte, numBytes, numBytes)
dstI := 0
for y := 0; y < ny; y++ {
srcI := y * int(stride)
for x := 0; x < nx; x++ {
if data32[srcI] == 0 && data32[srcI+1] == 0 && data32[srcI+2] == 0 {
copy(data64[dstI:dstI+8], ZeroBytes())
} else {
superpixelBytes[5] = data32[srcI+2]
superpixelBytes[6] = data32[srcI+1]
superpixelBytes[7] = data32[srcI]
copy(data64[dstI:dstI+8], superpixelBytes)
}
// NOTE: we skip the 4th byte (alpha) at srcI+3
//a := uint32(data32[srcI+3])
//b := uint32(data32[srcI+2])
//g := uint32(data32[srcI+1])
//r := uint32(data32[srcI+0])
//spid := (b << 16) | (g << 8) | r
srcI += 4
dstI += 8
}
}
return data64, nil
}