Documentation ¶
Overview ¶
Package imageblk implements DVID support for image blocks of various formats (uint8, uint16, rgba8). For label data, use labelblk.
Index ¶
- Constants
- Variables
- func DecodeTKey(tk storage.TKey) (*dvid.IndexZYX, error)
- func NewTKey(idx dvid.Index) storage.TKey
- func NewTKeyByCoord(izyx dvid.IZYXString) storage.TKey
- type ArbSlice
- type Block
- type Data
- func (d *Data) AllocateBlock() []byte
- func (d *Data) BackgroundBlock() []byte
- func (d *Data) BlankImage(dstW, dstH int32) (*dvid.Image, error)
- func (d *Data) BlockSize() dvid.Point
- func (d *Data) CopyPropertiesFrom(src datastore.DataService, fs storage.FilterSpec) error
- func (d *Data) DoRPC(req datastore.Request, reply *datastore.Response) error
- func (d *Data) Equals(d2 *Data) bool
- func (d *Data) Extents() *dvid.Extents
- func (d *Data) ForegroundROI(req datastore.Request, reply *datastore.Response) error
- func (d *Data) GetArbitraryImage(ctx storage.Context, tlStr, trStr, blStr, resStr string) (*dvid.Image, error)
- func (d *Data) GetBlocks(v dvid.VersionID, start dvid.ChunkPoint3d, span int32) ([]byte, error)
- func (d *Data) GetImage(v dvid.VersionID, vox *Voxels, roiname dvid.InstanceName) (*dvid.Image, error)
- func (d *Data) GetVolume(v dvid.VersionID, vox *Voxels, roiname dvid.InstanceName) ([]byte, error)
- func (d *Data) GetVoxels(v dvid.VersionID, vox *Voxels, roiname dvid.InstanceName) error
- func (d *Data) GobDecode(b []byte) error
- func (d *Data) GobEncode() ([]byte, error)
- func (d *Data) Help() string
- func (d *Data) IngestVoxels(v dvid.VersionID, vox *Voxels, roiname dvid.InstanceName) error
- func (d *Data) LoadImages(v dvid.VersionID, offset dvid.Point, filenames []string) error
- func (d *Data) MarshalJSON() ([]byte, error)
- func (d *Data) ModifyConfig(config dvid.Config) error
- func (d *Data) MutateVoxels(v dvid.VersionID, vox *Voxels, roiname dvid.InstanceName) error
- func (d *Data) NewArbSlice(topLeft, topRight, bottomLeft dvid.Vector3d, res float64) (*ArbSlice, error)
- func (d *Data) NewArbSliceFromStrings(tlStr, trStr, blStr, resStr, sep string) (*ArbSlice, error)
- func (d *Data) NewFilter(fs storage.FilterSpec) (storage.Filter, error)
- func (d *Data) NewVoxels(geom dvid.Geometry, img interface{}) (*Voxels, error)
- func (d *Data) PushData(p *datastore.PushSession) error
- func (d *Data) PutBlocks(v dvid.VersionID, start dvid.ChunkPoint3d, span int, data io.ReadCloser, ...) error
- func (d *Data) PutChunk(chunk *storage.Chunk, putbuffer storage.RequestBuffer) error
- func (d *Data) PutLocal(request datastore.Request, reply *datastore.Response) error
- func (d *Data) PutVoxels(v dvid.VersionID, vox *Voxels, roiname dvid.InstanceName, mutate bool) error
- func (d *Data) ReadChunk(chunk *storage.Chunk) error
- func (d *Data) Resolution() dvid.Resolution
- func (d *Data) ServeHTTP(uuid dvid.UUID, ctx *datastore.VersionedCtx, w http.ResponseWriter, ...)
- func (d *Data) SetExtents(uuid dvid.UUID, jsonBytes []byte) error
- func (d *Data) String() string
- type Filter
- type KeyFunc
- type MutatedBlock
- type PopulateFunc
- type Properties
- type ROI
- type Type
- type ValueCache
- type Voxels
- func (v *Voxels) BytesPerVoxel() int32
- func (v *Voxels) ComputeTransform(block *storage.TKeyValue, blockSize dvid.Point) (blockBeg, dataBeg, dataEnd dvid.Point, err error)
- func (v *Voxels) Data() []byte
- func (v *Voxels) DownRes(magnification dvid.Point) error
- func (v *Voxels) GetImage2d() (*dvid.Image, error)
- func (v *Voxels) IndexIterator(chunkSize dvid.Point) (dvid.IndexIterator, error)
- func (v *Voxels) Interpolable() bool
- func (v *Voxels) NewChunkIndex() dvid.ChunkIndexer
- func (v *Voxels) ReadBlock(block *storage.TKeyValue, blockSize dvid.Point, attenuation uint8) error
- func (v *Voxels) SetData(data []byte)
- func (v *Voxels) SetGeometry(geom dvid.Geometry)
- func (v *Voxels) SetStride(stride int32)
- func (v *Voxels) SetValues(values dvid.DataValues)
- func (v *Voxels) Stride() int32
- func (v *Voxels) String() string
- func (v *Voxels) Values() dvid.DataValues
- func (v *Voxels) WriteBlock(block *storage.TKeyValue, blockSize dvid.Point) error
Constants ¶
const ( Version = "0.2" RepoURL = "github.com/janelia-flyem/dvid/datatype/imageblk" )
const ( IngestBlockEvent = "BLOCK_INGEST" MutateBlockEvent = "BLOCK_MUTATE" DeleteBlockEvent = "BLOCK_DELETE" )
Events for imageblk
const HelpMessage = `` /* 13684-byte string literal not displayed */
const KVWriteSize = 500
KVWriteSize is the # of key-value pairs we will write as one atomic batch write.
Variables ¶
var ( // DefaultBlockSize specifies the default size for each block of this data type. DefaultBlockSize int32 = 32 DefaultRes float32 = 8 DefaultUnits = "nanometers" )
Functions ¶
func DecodeTKey ¶
DecodeTKey returns a spatial index from a image block key. TODO: Extend this when necessary to allow any form of spatial indexing like CZYX.
func NewTKeyByCoord ¶
func NewTKeyByCoord(izyx dvid.IZYXString) storage.TKey
NewTKeyByCoord returns a TKey for a block coord in string format.
Types ¶
type ArbSlice ¶
type ArbSlice struct {
// contains filtered or unexported fields
}
ArbSlice is a 2d rectangle that can be positioned arbitrarily in 3D.
type Block ¶
Block encodes a 3d block coordinate and block data. It is the unit of delta for a IngestBlockEvent.
type Data ¶
type Data struct { *datastore.Data Properties }
Data embeds the datastore's Data and extends it with voxel-specific properties.
func (*Data) AllocateBlock ¶ added in v0.8.0
func (*Data) BackgroundBlock ¶
BackgroundBlock returns a block buffer that has been preinitialized to the background value.
func (*Data) BlankImage ¶
BlankImage initializes a blank image of appropriate size and depth for the current data values. Returns an error if the geometry is not 2d.
func (*Data) CopyPropertiesFrom ¶ added in v0.8.2
func (d *Data) CopyPropertiesFrom(src datastore.DataService, fs storage.FilterSpec) error
CopyPropertiesFrom copies the data instance-specific properties from a given data instance into the receiver's properties.
func (*Data) ForegroundROI ¶
ForegroundROI creates a new ROI by determining all non-background blocks.
func (*Data) GetArbitraryImage ¶
func (*Data) GetBlocks ¶
GetBlocks returns a slice of bytes corresponding to all the blocks along a span in X
func (*Data) GetImage ¶
func (d *Data) GetImage(v dvid.VersionID, vox *Voxels, roiname dvid.InstanceName) (*dvid.Image, error)
GetImage retrieves a 2d image from a version node given a geometry of voxels.
func (*Data) GetVolume ¶
GetVolume retrieves a n-d volume from a version node given a geometry of voxels.
func (*Data) GetVoxels ¶
GetVoxels copies voxels from the storage engine to Voxels, a requested subvolume or 2d image.
func (*Data) IngestVoxels ¶ added in v0.8.0
IngestVoxels ingests voxels from a subvolume into the storage engine. The subvolume must be aligned to blocks of the data instance, which simplifies the routine since we are simply replacing a value instead of modifying values (GET + PUT).
func (*Data) LoadImages ¶
LoadImages bulk loads images using different techniques if it is a multidimensional file like HDF5 or a sequence of PNG/JPG/TIF images.
func (*Data) MarshalJSON ¶
func (*Data) MutateVoxels ¶ added in v0.8.0
MutateVoxels mutates voxels from a subvolume into the storage engine. This differs from the IngestVoxels function in firing off a MutateBlockEvent instead of an IngestBlockEvent, which tells subscribers that a previous value has changed instead of a completely new key/value being inserted. There will be some decreased performance due to cleanup of prior denormalizations compared to IngestVoxels.
func (*Data) NewArbSlice ¶
func (d *Data) NewArbSlice(topLeft, topRight, bottomLeft dvid.Vector3d, res float64) (*ArbSlice, error)
NewArbSlice returns an image with arbitrary 3D orientation. The 3d points are in real world space definited by resolution, e.g., nanometer space.
func (*Data) NewArbSliceFromStrings ¶
NewArbSliceFromStrings returns an image with arbitrary 3D orientation given string parameters. The 3d points are in real world space definited by resolution, e.g., nanometer space.
func (*Data) NewFilter ¶ added in v0.8.2
NewFilter returns a Filter for use with a push of key-value pairs.
func (*Data) NewVoxels ¶
NewVoxels returns Voxels with given geometry and optional image data. If img is passed in, the function will initialize the Voxels with data from the image. Otherwise, it will allocate a zero buffer of appropriate size.
func (*Data) PushData ¶ added in v0.8.2
func (d *Data) PushData(p *datastore.PushSession) error
PushData does an imageblk-specific push using optional ROI filters.
func (*Data) PutBlocks ¶
func (d *Data) PutBlocks(v dvid.VersionID, start dvid.ChunkPoint3d, span int, data io.ReadCloser, mutate bool) error
PutBlocks stores blocks of data in a span along X
func (*Data) PutChunk ¶
PutChunk puts 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) PutLocal ¶
PutLocal adds image data to a version node, altering underlying blocks if the image intersects the block.
The image filename glob MUST BE absolute file paths that are visible to the server. This function is meant for mass ingestion of large data files, and it is inappropriate to read gigabytes of data just to send it over the network to a local DVID.
func (*Data) PutVoxels ¶
func (d *Data) PutVoxels(v dvid.VersionID, vox *Voxels, roiname dvid.InstanceName, mutate bool) error
PutVoxels persists voxels from a subvolume into the storage engine. The subvolume must be aligned to blocks of the data instance, which simplifies the routine if the PUT is a mutation (signals MutateBlockEvent) instead of ingestion.
func (*Data) ReadChunk ¶
ReadChunk reads 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) Resolution ¶
func (d *Data) Resolution() dvid.Resolution
func (*Data) ServeHTTP ¶
func (d *Data) ServeHTTP(uuid dvid.UUID, ctx *datastore.VersionedCtx, w http.ResponseWriter, r *http.Request)
ServeHTTP handles all incoming HTTP requests for this data.
func (*Data) SetExtents ¶ added in v0.8.3
SetExtents loads JSON data giving MinPoint and MaxPoint.
type Filter ¶ added in v0.8.2
type Filter struct { *Data // contains filtered or unexported fields }
type MutatedBlock ¶ added in v0.8.0
MutatedBlock encodes a 3d block coordinate and previous and updated block data. It is the unit of delta for a MutateBlockEvent.
type PopulateFunc ¶
type Properties ¶
type Properties struct { // Values describes the data type/label for each value within a voxel. Values dvid.DataValues // Interpolable is true if voxels can be interpolated when resizing. Interpolable bool // Block size for this repo BlockSize dvid.Point dvid.Resolution dvid.Extents // The only mutable property. TODO -- move to in-memory store. // Background value for data Background uint8 }
Properties are additional properties for image block data instances beyond those in standard datastore.Data. These will be persisted to metadata storage.
func (*Properties) NdDataMetadata ¶
func (p *Properties) NdDataMetadata() (string, error)
NdDataSchema returns the metadata in JSON for this Data
type ROI ¶
ROI encapsulates a request-specific ROI check with a given scaling for voxels outside the ROI.
type Type ¶
Type embeds the datastore's Type to create a unique type with voxel functions. Refinements of general voxel types can be implemented by embedding this type, choosing appropriate # of values and bytes/value, overriding functions as needed, and calling datastore.Register(). Note that these fields are invariant for all instances of this type. Fields that can change depending on the type of data (e.g., resolution) should be in the Data type.
func NewType ¶
func NewType(values dvid.DataValues, interpolable bool) Type
NewType returns a pointer to a new imageblk Type with default values set.
func (*Type) NewData ¶
func (dtype *Type) NewData(uuid dvid.UUID, id dvid.InstanceID, name dvid.InstanceName, c dvid.Config) (*Data, error)
NewData returns a pointer to a new Voxels with default values.
func (*Type) NewDataService ¶
func (dtype *Type) NewDataService(uuid dvid.UUID, id dvid.InstanceID, name dvid.InstanceName, c dvid.Config) (datastore.DataService, error)
NewDataService returns a pointer to a new Voxels with default values.
type ValueCache ¶
ValueCache is a concurrency-friendly cache
func NewValueCache ¶
func NewValueCache(size int) *ValueCache
func (ValueCache) Get ¶
func (vc ValueCache) Get(key []byte, pf PopulateFunc) ([]byte, bool, error)
Get returns the cached value of a key. On a miss, it uses the passed PopulateFunc to retrieve the key and stores it in the cache. If nil is passed for the PopulateFunc, the function just returns a "false" with no value.
type Voxels ¶
Voxels represents subvolumes or slices and implements the ExtData interface.
func (*Voxels) BytesPerVoxel ¶
func (*Voxels) ComputeTransform ¶
func (v *Voxels) ComputeTransform(block *storage.TKeyValue, blockSize dvid.Point) (blockBeg, dataBeg, dataEnd dvid.Point, err error)
ComputeTransform determines the block coordinate and beginning + ending voxel points for the data corresponding to the given Block.
func (*Voxels) DownRes ¶
DownRes downsamples 2d Voxels data by averaging where the down-magnification are integers. If the source image size in Voxels is not an integral multiple of the reduction factor, the edge voxels on the right and bottom side are truncated. This function modifies the Voxels data. An error is returned if a non-2d Voxels receiver is used.
func (*Voxels) GetImage2d ¶
GetImage2d returns a 2d image suitable for use external to DVID. TODO -- Create more comprehensive handling of endianness and encoding of multibytes/voxel data into appropriate images.
func (*Voxels) IndexIterator ¶
IndexIterator returns an iterator that can move across the voxel geometry, generating indices or index spans.
func (*Voxels) Interpolable ¶
func (*Voxels) NewChunkIndex ¶
func (v *Voxels) NewChunkIndex() dvid.ChunkIndexer
func (*Voxels) ReadBlock ¶
ReadBlock reads the possibly intersecting block data into the receiver Voxels.
func (*Voxels) SetGeometry ¶
func (*Voxels) SetValues ¶
func (v *Voxels) SetValues(values dvid.DataValues)
func (*Voxels) Values ¶
func (v *Voxels) Values() dvid.DataValues