Documentation ¶
Index ¶
- Constants
- func DilateDimension(pos, max, dilationFactor int, direction string) int
- func ImageFromBytes(imgBytes []byte) (image.Image, error)
- func LabeledPixelToID(c color.Color) (uint32, error)
- func OpenImageFromLocalFile(filePath string) (image.Image, error)
- func OpenImageFromLocalFileOrGoogleStorage(filePath string, storageClient *storage.Client) (image.Image, error)
- func SubsetAndRescaleImage(baseImg image.Image, ...) (image.Image, error)
- type CentralMoments
- type Connected
- func (c *Connected) ComputeMoments(component ConnectedComponent, method MomentMethod) (CentralMoments, error)
- func (c *Connected) Count(l LabelMap, threshold int) (rawPixels, rawCounts, thresholdedPixels, thresholdedCounts map[Label]int, ...)
- func (c Connected) LabelAbove(x, y int) (bool, uint32)
- func (c Connected) LabelLeft(x, y int) (bool, uint32)
- type ConnectedComponent
- type Coord
- type JSONConfig
- type Label
- type LabelMap
- func (l LabelMap) DecodeImageFromImageSegment(bmpImage image.Image, transparentBackground bool) (image.Image, error)
- func (l LabelMap) DecodeImageFromRLE(rleBytes []byte, maxX, maxY int) (image.Image, error)
- func (l LabelMap) EncodeImageToImageSegment(bmpImage image.Image) (image.Image, error)
- func (l LabelMap) EncodeImageToRLE(bmpImage image.Image) ([]byte, error)
- func (l LabelMap) Sorted() []Label
- func (l LabelMap) ToIDMap() map[uint]Label
- func (l LabelMap) Valid() bool
- type MomentMethod
Constants ¶
const ( WhichPointBottomRight = "br" WhichPointTopLeft = "tl" )
const SpecialTransparentColor = "#000001"
SpecialTransparentColor is a color which will render as transparent.
Variables ¶
This section is empty.
Functions ¶
func DilateDimension ¶
DilateDimension expands an axis by "dilationFactor" pixels (additive). It basically adds or subtracts pixels, while paying attention to not allow the lower bound of the image to go below 0.
func ImageFromBytes ¶
ImageFromBytes creates an image from the specified bytes. Must be PNG, GIF, BMP, or JPEG formatted (based on the decoders we have imported).
func LabeledPixelToID ¶
LabeledPixelToID converts the label-encoded pixel (e.g., #010101) which is alpha-premultiplied into an ID in the range of 0-255
func OpenImageFromLocalFile ¶
OpenImageFromLocalFile pulls an image with the specified suffix (derived from the DICOM name) from a local folder
func SubsetAndRescaleImage ¶
func SubsetAndRescaleImage(baseImg image.Image, topLeftX, topLeftY, bottomRightX, bottomRightY, scale, dilation int) (image.Image, error)
SubsetAndRescaleImage takes an input image, crops based on a top left point and a bottom right point, dilates, and then rescales the image.
Types ¶
type CentralMoments ¶
type Connected ¶
type Connected struct { // Each point represents a label ID PixelLabelIDs [][]uint8 // Each point represents a connected component ID PixelConnectedComponentIDs [][]uint32 // Each component of each label is tracked, including bounding box and pixel count LabeledConnectedComponents map[uint8]map[uint32]ConnectedComponent }
func (*Connected) ComputeMoments ¶
func (c *Connected) ComputeMoments(component ConnectedComponent, method MomentMethod) (CentralMoments, error)
func (*Connected) Count ¶
func (c *Connected) Count(l LabelMap, threshold int) (rawPixels, rawCounts, thresholdedPixels, thresholdedCounts map[Label]int, err error)
Count evaluates the number of pixels for each label, the number of components for each label, and then also performs the same operations on a subset of the data that requires that a threshold be met (in terms of number of pixels within a contiguous component) in order to be counted. This permits you to, e.g., ignore single-pixel noisy blips that appear and which shouldn't be counted towards area measurements.
type ConnectedComponent ¶
type ConnectedComponent struct { LabelID uint8 ComponentID uint32 PixelCount int Bounds struct { TopLeft Coord BottomRight Coord } }
func MergeConnectedComponentsSameLabel ¶
func MergeConnectedComponentsSameLabel(c1, c2 ConnectedComponent) ConnectedComponent
MergeConnectedComponents brings two ConnectedComponents together. In doing so, it assumes that the LabelID is the same between the two (and sets it to the LabelID of the first, regardless). It unsets the component ID - this merged value is now only useful in the context of doing a summary level evaluation on the whole label.
type JSONConfig ¶
type JSONConfig struct { ConfigPath string ManifestPath string `json:"manifest"` Port int `json:"port"` Labels LabelMap `json:"labels"` LabelPath string `json:"label_path"` ImagePath string `json:"image_path"` ImageSuffix string `json:"image_suffix"` DefaultBrush string `json:"default_brush"` PreParsed bool `json:"preparsed"` BrushSize int `json:"brush_size,omitempty"` }
func ParseJSONConfigFromPath ¶
func ParseJSONConfigFromPath(path string) (JSONConfig, error)
type Label ¶
type Label struct { Label string ID uint `json:"id"` Color string `json:"color"` SortOrder float64 `json:"sort_order,omitempty"` }
A Label tracks the segmentation ID with the human-identifiable Label and human-interpretable color (in RGB hex, e.g., #FF0000 for red).
type LabelMap ¶
LabelMap ([string label name]Label) keeps track of the relationship between human-visible colors and the segmentation ID (used for deep learning) of that label.
func (LabelMap) DecodeImageFromImageSegment ¶
func (l LabelMap) DecodeImageFromImageSegment(bmpImage image.Image, transparentBackground bool) (image.Image, error)
DecodeImageFromImageSegment consumes an ID-encoded image (where each pixel is #010101 for ID 1, #020202 for ID 2 etc), and transforms it into a human-visible value based on the colors for those IDs assigned in the config file. It special-cases ID 0 (the background) and color value #000001 to be transparent. However, if transparentBackground is false, then the background is set to black.
func (LabelMap) DecodeImageFromRLE ¶
func (LabelMap) EncodeImageToImageSegment ¶
EncodeImageToImageSegment consumes a multi-color human-visible image into an image where each pixel has the same R, G, and B value mapped to the integer ID of the Label. For example, if background is transparent (ID 0) and the left atrium is red (ID 1), it will produce an image that is all black, with values #000000 for the background and #010101 for the left atrium.
func (LabelMap) EncodeImageToRLE ¶
type MomentMethod ¶
type MomentMethod uint8
const ( MomentMethodConnected MomentMethod = iota MomentMethodLabel )