labelmap

package
v0.0.0-...-e545f54 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 6, 2014 License: BSD-3-Clause Imports: 25 Imported by: 0

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

View Source
const (
	Version = "0.1"
	RepoUrl = "github.com/janelia-flyem/dvid/datatype/labelmap"
)
View Source
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

func (d *Data) ApplyLabelMap(request datastore.Request, reply *datastore.Response) error

ApplyLabelMap creates a new labels64 by applying a label map to existing labels64 data.

func (*Data) ChunkApplyMap

func (d *Data) ChunkApplyMap(chunk *storage.Chunk)

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

func (d *Data) DenormalizeChunk(chunk *storage.Chunk)

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) DoHTTP

func (d *Data) DoHTTP(uuid dvid.UUID, w http.ResponseWriter, r *http.Request) error

DoHTTP handles all incoming HTTP requests for this data.

func (*Data) DoRPC

func (d *Data) DoRPC(request datastore.Request, reply *datastore.Response) error

DoRPC acts as a switchboard for RPC commands.

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

func (d *Data) GetLabelAtPoint(uuid dvid.UUID, pt dvid.Point) (uint64, error)

GetLabelAtPoint returns a mapped label for a given point.

func (*Data) GetLabelMapping

func (d *Data) GetLabelMapping(versionID dvid.VersionLocalID, label []byte) (uint64, error)

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

func (d *Data) GetMappedImage(uuid dvid.UUID, e voxels.ExtHandler) (*dvid.Image, error)

GetMappedImage retrieves a 2d image from a version node given a geometry of voxels.

func (*Data) GetMappedVolume

func (d *Data) GetMappedVolume(uuid dvid.UUID, e voxels.ExtHandler) ([]byte, error)

GetMappedVolume retrieves a n-d volume from a version node given a geometry of voxels.

func (*Data) GetMappedVoxels

func (d *Data) GetMappedVoxels(uuid dvid.UUID, e voxels.ExtHandler) error

GetMappedVoxels copies mapped labels for each voxel for a version to an ExtHandler, e.g., a requested subvolume or 2d image.

func (*Data) GetSparseVol

func (d *Data) GetSparseVol(uuid dvid.UUID, label uint64) ([]byte, error)

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

func (d *Data) GetSurface(uuid dvid.UUID, label uint64) (s []byte, found bool, err error)

GetSurface returns a byte array with # voxels and float32 arrays for vertices and normals.

func (*Data) JSONString

func (d *Data) JSONString() (jsonStr string, err error)

JSONString returns the JSON for this Data's configuration

func (*Data) LoadRavelerMaps

func (d *Data) LoadRavelerMaps(request datastore.Request, reply *datastore.Response) error

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

func (d *Data) MapChunk(chunk *storage.Chunk)

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

func (d *Data) ProcessSpatially(uuid dvid.UUID)

Iterate through all blocks in the associated label volume, computing the spatial indices for bodies and the mappings for each spatial index.

type Datatype

type Datatype struct {
	datastore.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) Help

func (dtype *Datatype) Help() string

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

func (ref *LabelsRef) GetData() (*labels64.Data, error)

GetData returns a pointer to the referenced labels and stores the pointer into the reference.

func (LabelsRef) MarshalBinary

func (ref LabelsRef) MarshalBinary() ([]byte, error)

MarshalBinary fulfills the encoding.BinaryMarshaler interface.

func (LabelsRef) MarshalJSON

func (ref LabelsRef) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (LabelsRef) String

func (ref LabelsRef) String() string

func (*LabelsRef) UnmarshalBinary

func (ref *LabelsRef) UnmarshalBinary(data []byte) error

UnmarshalBinary fulfills the encoding.BinaryUnmarshaler interface.

func (*LabelsRef) UnmarshalJSON

func (ref *LabelsRef) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

type Superpixel

type Superpixel struct {
	Slice uint32
	Label uint32
}

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

type SuperpixelImage interface {
	image.Image
}

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.

type Superpixels

type Superpixels []Superpixel

Superpixels is a slice of Superpixel type

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL