Documentation ¶
Overview ¶
Package labelmap implements DVID support for label->label mapping including spatial index tracking.
NOTE: Zero value labels are reserved and useful for setting something as background.
Index ¶
- Constants
- func GetSuperpixelId(superpixels SuperpixelImage, x int, y int, format SuperpixelFormat) (id uint32, err error)
- type Data
- func (d *Data) ApplyLabelMap(request datastore.Request, reply *datastore.Response) error
- func (d *Data) ChunkApplyMap(chunk *storage.Chunk)
- func (d *Data) DenormalizeChunk(chunk *storage.Chunk)
- func (d *Data) DoHTTP(uuid dvid.UUID, w http.ResponseWriter, r *http.Request) error
- func (d *Data) DoRPC(request datastore.Request, reply *datastore.Response) error
- func (d *Data) GetBlockLayerMapping(blockZ int32, op *denormOp) (minChunkPt, maxChunkPt dvid.ChunkPoint3d, err error)
- func (d *Data) GetBlockMapping(vID dvid.VersionLocalID, block dvid.IndexZYX) (map[string]uint64, error)
- func (d *Data) GetLabelAtPoint(uuid dvid.UUID, pt dvid.Point) (uint64, error)
- func (d *Data) GetLabelMapping(versionID dvid.VersionLocalID, label []byte) (uint64, error)
- func (d *Data) GetLabelsInVolume(uuid dvid.UUID, minBlock, maxBlock dvid.ChunkPoint3d) (string, error)
- func (d *Data) GetMappedImage(uuid dvid.UUID, e voxels.ExtHandler) (*dvid.Image, error)
- func (d *Data) GetMappedVolume(uuid dvid.UUID, e voxels.ExtHandler) ([]byte, error)
- func (d *Data) GetMappedVoxels(uuid dvid.UUID, e voxels.ExtHandler) error
- func (d *Data) GetSparseVol(uuid dvid.UUID, label uint64) ([]byte, error)
- func (d *Data) GetSurface(uuid dvid.UUID, label uint64) (s []byte, found bool, err error)
- func (d *Data) JSONString() (jsonStr string, err error)
- func (d *Data) LoadRavelerMaps(request datastore.Request, reply *datastore.Response) error
- func (d *Data) MapChunk(chunk *storage.Chunk)
- func (d *Data) NewRavelerForwardMapKey(vID dvid.VersionLocalID, z, spid uint32, body uint64) *datastore.DataKey
- func (d *Data) ProcessSpatially(uuid dvid.UUID)
- type Datatype
- type LabelsRef
- func (ref *LabelsRef) GetData() (*labels64.Data, error)
- func (ref LabelsRef) MarshalBinary() ([]byte, error)
- func (ref LabelsRef) MarshalJSON() ([]byte, error)
- func (ref LabelsRef) String() string
- func (ref *LabelsRef) UnmarshalBinary(data []byte) error
- func (ref *LabelsRef) UnmarshalJSON(b []byte) error
- type Superpixel
- type SuperpixelFormat
- type SuperpixelImage
- type Superpixels
Constants ¶
const ( Version = "0.1" RepoUrl = "github.com/janelia-flyem/dvid/datatype/labelmap" )
const HelpMessage = `` /* 8277-byte string literal not displayed */
Variables ¶
This section is empty.
Functions ¶
func GetSuperpixelId ¶
func GetSuperpixelId(superpixels SuperpixelImage, x int, y int, format SuperpixelFormat) (id uint32, err error)
GetSuperpixelID returns the superpixel id at a given coord within a superpixel image. This routine handles 24-bit and 16-bit superpixel images.
Types ¶
type Data ¶
type Data struct { *datastore.Data // Labels64 data that we will be mapping. Labels LabelsRef // Ready is true if inverse map, forward map, and spatial queries are ready. Ready bool }
Data embeds the datastore's Data and extends it with keyvalue properties (none for now).
func (*Data) ApplyLabelMap ¶
ApplyLabelMap creates a new labels64 by applying a label map to existing labels64 data.
func (*Data) ChunkApplyMap ¶
ChunkApplyMap maps a chunk of labels using the current mapping. Only some multiple of the # of CPU cores can be used for chunk handling before it waits for chunk processing to abate via the buffered server.HandlerToken channel.
func (*Data) DenormalizeChunk ¶
DenormalizeChunk processes a chunk of data as part of a mapped operation. Only some multiple of the # of CPU cores can be used for chunk handling before it waits for chunk processing to abate via the buffered server.HandlerToken channel.
func (*Data) GetBlockLayerMapping ¶
func (d *Data) GetBlockLayerMapping(blockZ int32, op *denormOp) (minChunkPt, maxChunkPt dvid.ChunkPoint3d, err error)
GetBlockLayerMapping gets the label mapping for a Z layer of blocks and stores the result in the passed Operation.
func (*Data) GetBlockMapping ¶
func (d *Data) GetBlockMapping(vID dvid.VersionLocalID, block dvid.IndexZYX) (map[string]uint64, error)
GetBlockMapping returns the label -> mappedLabel map for a given block.
func (*Data) GetLabelAtPoint ¶
GetLabelAtPoint returns a mapped label for a given point.
func (*Data) GetLabelMapping ¶
GetLabelMapping returns the mapping for a label.
func (*Data) GetLabelsInVolume ¶
func (d *Data) GetLabelsInVolume(uuid dvid.UUID, minBlock, maxBlock dvid.ChunkPoint3d) (string, error)
GetLabelsInVolume returns a JSON list of mapped labels that intersect a volume bounded by the specified block coordinates. Note that the blocks are specified using block coordinates, so if this data instance has 32 x 32 x 32 voxel blocks, and we specify min block (1,2,3) and max block (3,4,5), the subvolume in voxels will be from min voxel point (32, 64, 96) to max voxel point (96, 128, 160).
func (*Data) GetMappedImage ¶
GetMappedImage retrieves a 2d image from a version node given a geometry of voxels.
func (*Data) GetMappedVolume ¶
GetMappedVolume retrieves a n-d volume from a version node given a geometry of voxels.
func (*Data) GetMappedVoxels ¶
GetMappedVoxels copies mapped labels for each voxel for a version to an ExtHandler, e.g., a requested subvolume or 2d image.
func (*Data) GetSparseVol ¶
GetSparseVol returns an encoded sparse volume given a label. The encoding has the following format where integers are little endian:
byte Payload descriptor: Bit 0 (LSB) - 8-bit grayscale Bit 1 - 16-bit grayscale Bit 2 - 16-bit normal ... uint8 Number of dimensions uint8 Dimension of run (typically 0 = X) byte Reserved (to be used later) uint32 # Voxels uint32 # Spans Repeating unit of: int32 Coordinate of run start (dimension 0) int32 Coordinate of run start (dimension 1) int32 Coordinate of run start (dimension 2) ... int32 Length of run bytes Optional payload dependent on first byte descriptor
func (*Data) GetSurface ¶
GetSurface returns a byte array with # voxels and float32 arrays for vertices and normals.
func (*Data) JSONString ¶
JSONString returns the JSON for this Data's configuration
func (*Data) LoadRavelerMaps ¶
LoadRavelerMaps loads maps from Raveler-formatted superpixel->segment and segment->body maps. Ignores any mappings that are in slices outside associated labels64 volume.
func (*Data) MapChunk ¶
MapChunk processes a chunk of label data, storing the mapped labels. The data may be thinner, wider, and longer than the chunk, depending on the data shape (XY, XZ, etc). Only some multiple of the # of CPU cores can be used for chunk handling before it waits for chunk processing to abate via the buffered server.HandlerToken channel.
func (*Data) NewRavelerForwardMapKey ¶
func (d *Data) NewRavelerForwardMapKey(vID dvid.VersionLocalID, z, spid uint32, body uint64) *datastore.DataKey
NewRavelerForwardMapKey returns a datastore.DataKey that encodes a "label + mapping", where the label is a uint64 with top 4 bytes encoding Z and least-significant 4 bytes encoding the superpixel ID. Also, the zero label is reserved.
func (*Data) ProcessSpatially ¶
Iterate through all blocks in the associated label volume, computing the spatial indices for bodies and the mappings for each spatial index.
type Datatype ¶
Datatype embeds the datastore's Datatype to create a unique type for labelmap functions.
func NewDatatype ¶
func NewDatatype() (dtype *Datatype)
NewDatatype returns a pointer to a new labelmap Datatype with default values set.
func (*Datatype) NewDataService ¶
func (dtype *Datatype) NewDataService(id *datastore.DataID, c dvid.Config) (datastore.DataService, error)
NewData returns a pointer to new labelmap data with default values.
type LabelsRef ¶
type LabelsRef struct {
// contains filtered or unexported fields
}
LabelsRef is a reference to an existing labels64 data
func NewLabelsRef ¶
func NewLabelsRef(name dvid.DataString, dset dvid.DatasetLocalID) (LabelsRef, error)
func (*LabelsRef) GetData ¶
GetData returns a pointer to the referenced labels and stores the pointer into the reference.
func (LabelsRef) MarshalBinary ¶
MarshalBinary fulfills the encoding.BinaryMarshaler interface.
func (LabelsRef) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface.
func (*LabelsRef) UnmarshalBinary ¶
UnmarshalBinary fulfills the encoding.BinaryUnmarshaler interface.
func (*LabelsRef) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface.
type Superpixel ¶
Superpixel is a Raveler-oriented description of a superpixel that breaks a unique superpixel id into two components: a slice and a unique label within that slice.
type SuperpixelFormat ¶
type SuperpixelFormat uint8
SuperpixelFormat notes whether superpixel ids, if present, are in 16-bit or 24-bit values.
const ( SuperpixelNone SuperpixelFormat = iota Superpixel16Bits Superpixel24Bits )
Enumerate the types of superpixel id formats
type SuperpixelImage ¶
SuperpixelImage is an image with each pixel encoding a unique superpixel id for that plane. Superpixel values must be 16-bit grayscale or 32-bit RGBA.