Documentation ¶
Overview ¶
Package image contains functions that mostly operate on image.Gray.
Logical Operations
And Or Xor Not Sub Equal Copy
Morphological Operations
Dilate Erode Open Close TopHat BotHat HitOrMiss Thin Skeleton LJSkeleton LJReconstitute
Remap Operations
ColorConvert RemapGray RemapRGBA
Channel Operations
ExtractChannel ReplaceChannel SwitchChannels CombineChannels
Various metrics
Histogram CDF Variance
Image types:
Patch - replicates a patch of colors across the plane like Uniform does for a single color Tile - replicates an image across the plane
Index ¶
- Variables
- func Alpha16ToGray16(a *image.Alpha16) *image.Gray16
- func Alpha16ToGray16Deep(a *image.Alpha16) *image.Gray16
- func AlphaAnd(img1, img2 *image.Alpha, offs image.Point) *image.Alpha
- func AlphaEqual(img1, img2 *image.Alpha, offs image.Point) bool
- func AlphaNot(img *image.Alpha) *image.Alpha
- func AlphaOr(img1, img2 *image.Alpha, offs image.Point) *image.Alpha
- func AlphaSub(img1, img2 *image.Alpha, offs image.Point) *image.Alpha
- func AlphaToGray(a *image.Alpha) *image.Gray
- func AlphaToGrayDeep(a *image.Alpha) *image.Gray
- func AlphaXor(img1, img2 *image.Alpha, offs image.Point) *image.Alpha
- func And(img1, img2 image.Image, offs image.Point) *image.Gray
- func AvgOp(values [][]uint8, support [][]bool) uint8
- func BotHat(img image.Image, support [][]bool) *image.Gray
- func CDF(hist []int) []float64
- func Close(img image.Image, support [][]bool) *image.Gray
- func ColorConvert(img *image.NRGBA, xfm *Aff5) *image.NRGBA
- func CombineChannels(chR, chG, chB, chA *image.Gray, scale bool) *image.RGBA
- func CopyAlpha(in *image.Alpha) *image.Alpha
- func CopyAlpha16(in *image.Alpha16) *image.Alpha16
- func CopyGray(in *image.Gray) *image.Gray
- func CopyGray16(in *image.Gray16) *image.Gray16
- func CopyRGBA(in *image.RGBA) *image.RGBA
- func CopyRGBA64(in *image.RGBA64) *image.RGBA64
- func CreateLutFromValues(values []float64) []uint8
- func Dilate(img image.Image, support [][]bool) *image.Gray
- func Displace(img draw.Image, r image.Rectangle, xchan image.Image, xoffs image.Point, ...)
- func Equal(img1, img2 image.Image, offs image.Point) bool
- func Erode(img image.Image, support [][]bool) *image.Gray
- func ExtractChannel(img *image.RGBA, ch int) *image.Gray
- func Gray16ToAlpha16(a *image.Gray16) *image.Alpha16
- func Gray16ToAlpha16Deep(g *image.Gray16) *image.Alpha16
- func GrayToAlpha(a *image.Gray) *image.Alpha
- func GrayToAlphaDeep(g *image.Gray) *image.Alpha
- func GrayToSupport(img *image.Gray) [][]bool
- func Histogram(img *image.Gray) ([]int, int, int)
- func HitOrMiss(img image.Image, support1, support2 [][]bool) *image.Gray
- func LJReconstitute(skels []*image.Gray, b [][]bool) *image.Gray
- func LJSkeleton(img image.Image, b [][]bool, n int) []*image.Gray
- func MaxOp(values [][]uint8, support [][]bool) uint8
- func MedOp(values [][]uint8, support [][]bool) uint8
- func MinOp(values [][]uint8, support [][]bool) uint8
- func Morphological(img image.Image, op func([][]uint8, [][]bool) uint8, support [][]bool, ...) *image.Gray
- func NLExpansionLut(n, start, end int, f util.NonLinear) []uint8
- func NewAlpha(w, h int, col color.Color) *image.Alpha
- func NewAlpha16(w, h int, col color.Color) *image.Alpha16
- func NewGray(w, h int, col color.Color) *image.Gray
- func NewGray16(w, h int, col color.Color) *image.Gray16
- func NewRGBA(w, h int, col color.Color) *image.RGBA
- func NewRGBA64(w, h int, col color.Color) *image.RGBA64
- func Not(img image.Image) *image.Gray
- func Open(img image.Image, support [][]bool) *image.Gray
- func Or(img1, img2 image.Image, offs image.Point) *image.Gray
- func PremulLut(lut []uint8) [][]uint8
- func ReadImage(name string) (image.Image, error)
- func RemapGray(img *image.Gray, lut []uint8) *image.Gray
- func RemapGray2RGBA(img image.Image, lut []color.Color) *image.RGBA
- func RemapRGB(img *image.RGBA, lutR, lutG, lutB []uint8) *image.RGBA
- func RemapRGBSingle(img *image.RGBA, lut []uint8) *image.RGBA
- func ReplaceChannel(img *image.RGBA, ch int, rep *image.Gray) *image.RGBA
- func SaveImage(img image.Image, name string) error
- func Skeleton(img image.Image) *image.Gray
- func Sub(img1, img2 image.Image, offs image.Point) *image.Gray
- func SupportToGray(suppt [][]bool) *image.Gray
- func SwitchChannels(img *image.RGBA, ch1, ch2 int) *image.RGBA
- func Thin(img image.Image) *image.Gray
- func ThinStep(img image.Image, support1, support2 [][]bool) *image.Gray
- func ToGray(img image.Image) *image.Gray
- func ToGray16(img image.Image) *image.Gray16
- func TopHat(img image.Image, support [][]bool) *image.Gray
- func Variance(img1, img2 *image.Gray) (float64, int)
- func Xor(img1, img2 image.Image, offs image.Point) *image.Gray
- type Aff5
- type Bit
- type Colorizer
- type Gray
- type Gray16
- type Image
- type NRGBA
- type NRGBA64
- type Patch
- type Point
- type RGBA
- type RGBA64
- type Rectangle
- type Tile
Constants ¶
This section is empty.
Variables ¶
var ( // Z0 the point itself Z0 = [][]bool{ {true}, } // Z4 3x3 Von Neumann 4-way Z4 = [][]bool{ {false, true, false}, {true, true, true}, {false, true, false}, } // X4 3x3 X X4 = [][]bool{ {true, false, true}, {false, true, false}, {true, false, true}, } // Z8 3x3 Moore 8-way Z8 = [][]bool{ {true, true, true}, {true, true, true}, {true, true, true}, } // Cross5x5 5x5 cross Cross5x5 = [][]bool{ {false, false, true, false, false}, {false, false, true, false, false}, {true, true, true, true, true}, {false, false, true, false, false}, {false, false, true, false, false}, } // X5 5x5 X X5 = [][]bool{ {true, false, false, false, true}, {false, true, false, true, false}, {false, false, true, false, false}, {false, true, false, true, false}, {true, false, false, false, true}, } // Star5x5 5x5 star Star5x5 = [][]bool{ {true, false, true, false, true}, {false, true, true, true, false}, {true, true, true, true, true}, {false, true, true, true, false}, {true, false, true, false, true}, } // Diamond5x5 5x5 diamond Diamond5x5 = [][]bool{ {false, false, true, false, false}, {false, true, true, true, false}, {true, true, true, true, true}, {false, true, true, true, false}, {false, false, true, false, false}, } // Ball5x5 5x5 ball Ball5x5 = [][]bool{ {false, true, true, true, false}, {true, true, true, true, true}, {true, true, true, true, true}, {true, true, true, true, true}, {false, true, true, true, false}, } // All5x5 5x5 block All5x5 = [][]bool{ {true, true, true, true, true}, {true, true, true, true, true}, {true, true, true, true, true}, {true, true, true, true, true}, {true, true, true, true, true}, } C11 = [][]bool{ {false, false, false}, {false, true, false}, {true, true, true}, } D11 = [][]bool{ {true, true, true}, {false, false, false}, {false, false, false}, } C12 = [][]bool{ {true, false, false}, {true, true, false}, {true, false, false}, } D12 = [][]bool{ {false, false, true}, {false, false, true}, {false, false, true}, } C13 = [][]bool{ {true, true, true}, {false, true, false}, {false, false, false}, } D13 = [][]bool{ {false, false, false}, {false, false, false}, {true, true, true}, } C14 = [][]bool{ {false, false, true}, {false, true, true}, {false, false, true}, } D14 = [][]bool{ {true, false, false}, {true, false, false}, {true, false, false}, } C21 = [][]bool{ {false, false, false}, {true, true, false}, {true, true, false}, } D21 = [][]bool{ {false, true, true}, {false, false, true}, {false, false, false}, } C22 = [][]bool{ {true, true, false}, {true, true, false}, {false, false, false}, } D22 = [][]bool{ {false, false, false}, {false, false, true}, {false, true, true}, } C23 = [][]bool{ {false, true, true}, {false, true, true}, {false, false, false}, } D23 = [][]bool{ {false, false, false}, {true, false, false}, {true, true, false}, } C24 = [][]bool{ {false, false, false}, {false, true, true}, {false, true, true}, } D24 = [][]bool{ {true, true, false}, {true, false, false}, {false, false, false}, } )
Functions ¶
func Alpha16ToGray16 ¶
Alpha16ToGray16 does a shallow copy (vs going through the ColorModel).
func Alpha16ToGray16Deep ¶
Alpha16ToGray16Deep does a deep copy (vs going through the ColorModel).
func AlphaAnd ¶
AlphaAnd returns img1 & img2 (intersection). For a pair of pixels, p1 & p2 returns min(p1, p2).
func AlphaEqual ¶
AlphaEqual returns true if two images are the same.
func AlphaOr ¶
AlphaOr returns img1 | img2 (union). For a pair of pixels, p1 | p2 returns max(p1, p2).
func AlphaSub ¶
AlphaSub returns img1 - img2 (img1 minus the intersection of img1 and img2). For a pair of pixels, p1 - p2 returns min(p1, 1-p2).
func AlphaToGray ¶
AlphaToGray does a shallow copy (vs going through the ColorModel).
func AlphaToGrayDeep ¶
AlphaToGrayDeep does a deep copy (vs going through the ColorModel).
func AlphaXor ¶
AlphaXor returns img1 ^ img2 (union - intersection). For a pair of pixels, p1 ^ p2 returns min(max(p1, p2), 1-min(p1, p2)).
func And ¶
And returns the result of ANDing img1 with img2, offset by offs (intersection). The images are converted to image.Gray if not already so. For a pair of pixels, p1 & p2 returns min(p1, p2).
func AvgOp ¶
AvgOp finds the average value (rounded down) of all the values that have the support set.
func ColorConvert ¶
ColorConvert runs NRGBA through the supplied affine transform.
func CombineChannels ¶
CombineChannels combines mono-channel images into a single image. The R, G, B channels will be scaled by alpha if scale is true.
func CopyAlpha16 ¶
CopyAlpha16 clones an Alpha16 image.
func CopyRGBA64 ¶
CopyRGBA64 clones an RGBA64 image.
func CreateLutFromValues ¶
CreateLutFromValues maps a series of values in [0,1] to [0,255] Note - no checking on values range
func Displace ¶
func Displace(img draw.Image, r image.Rectangle, xchan image.Image, xoffs image.Point, xscale float64, ychan image.Image, yoffs image.Point, yscale float64)
Displace displaces the image within the rectangle by the amounts referenced in the other two images (one each for X and Y) scaled. If the displaced location exceeds the bounds of the rectangle, it is wrapped. Black maps to scale * -0.5 and white to scale * 0.5.
func ExtractChannel ¶
ExtractChannel returns an image with just the selected channel. The returned image is scaled by 1/alpha, if not the alpha channel.
func Gray16ToAlpha16 ¶
Gray16ToAlpha16 does a shallow copy (vs going through the ColorModel).
func Gray16ToAlpha16Deep ¶
Gray16ToAlpha16Deep does a deep copy (vs going through the ColorModel).
func GrayToAlpha ¶
GrayToAlpha does a shallow copy (vs going through the ColorModel).
func GrayToAlphaDeep ¶
GrayToAlphaDeep does a deep copy (vs going through the ColorModel).
func GrayToSupport ¶
GrayToSupport converts a gray scale image to a support.
func Histogram ¶
Histogram computes the histogram of the image and the first and last non-zero entry positions
func HitOrMiss ¶
HitOrMiss keeps support1 and not support2 in the image. It requires that the intersection of the two supports be empty.
func LJReconstitute ¶
LJReconstitute turns a set of skeletons back into the opened version of the original image using the support.
func LJSkeleton ¶
LJSkeleton calculates the skeletons of the image using Lanuejoul's formula over n iterations with support b. Each skeleton is formed from the tophat of the image eroded by the support b dilated by itself n times. The last skeleton is the union of the previous skeletons. See https://en.wikipedia.org/wiki/Morphological_skeleton
func Morphological ¶
func Morphological(img image.Image, op func([][]uint8, [][]bool) uint8, support [][]bool, def uint8) *image.Gray
Morphological runs op over the image img using support and supplying def when a location falls outside of the image boundary. The support dimensions must be odd (not checked for).
func NLExpansionLut ¶
NLExpansionLut generates a lut [start,end), normalized and mapped through f. For example NLExpansionLut(256, 0, 256, &NLSin{}) will generate a Sin ramp.
func NewAlpha ¶
NewAlpha is a wrapper for image.Alpha which returns a new image of the desired size filled with color.
func NewAlpha16 ¶
NewAlpha16 is a wrapper for image.Alpha16 which returns a new image of the desired size filled with color.
func NewGray ¶
NewGray is a wrapper for image.Gray which returns a new image of the desired size filled with color.
func NewGray16 ¶
NewGray16 is a wrapper for image.Gray16 which returns a new image of the desired size filled with color.
func NewRGBA ¶
NewRGBA is a wrapper for image.RGBA which returns a new image of the desired size filled with color.
func NewRGBA64 ¶
NewRGBA64 is a wrapper for image.RGBA64 which returns a new image of the desired size filled with color.
func Or ¶
Or returns the result of ORing img1 with img2, offset by offs (union). The images are converted to image.Gray if not already so. For a pair of pixels, p1 & p2 returns max(p1, p2).
func RemapGray ¶
RemapGray remaps a color map with a look up table. The lookup table must be 256 long.
func RemapGray2RGBA ¶
RemapGray2RGBA remaps a grayscale image to an RGBA one using a look up table. The lookup table must be 256 long.
func RemapRGB ¶
RemapRGB remaps all the color maps with R, G, B look up tables. The lookup tables must all be 256 long. The maps are applied after alpha pre-multiplication.
func RemapRGBSingle ¶
RemapRGBSingle remaps all the color maps with a single look up table. The lookup table must be 256 long. The maps are applied after alpha pre-multiplication.
func ReplaceChannel ¶
ReplaceChannel in an image with the one supplied. The supplied image is scaled by alpha, if one of R, G or B. If the alpha channel is replaced then RGB are first scaled by 1/alpha and then by alpha'
func Skeleton ¶
Skeleton repeatedly thins the image until it's no longer changing. This operation can take a while to converge.
func Sub ¶
Sub returns the result of subtracting img2 from img1, offset by offs. The images are converted to image.Gray if not already so. For a pair of pixels, p1 & p2 returns max(0, p1-p2).
func SupportToGray ¶
SupportToGray converts a support to a gray scale image.
func SwitchChannels ¶
SwitchChannels in an image (not alpha)
func Thin ¶
Thin thins the image by repeatedly subtracting HitOrMiss with the selected support pairs.
Types ¶
type Aff5 ¶
type Aff5 [20]float64
Aff5 is a 5x5 affine transformation matrix in row major order, where the bottom row is implicitly [0 0 0 0 1].
m[5*r+c] is the element in the r'th row and c'th column.
func LuminanceToAlpha ¶
func LuminanceToAlpha() *Aff5
LuminanceToAlpha returns a transform that will write just the luminance to the alpha channel.
func Saturate ¶
Saturate returns a transform that will modify the saturation of an image by s (0, 1)
type Bit ¶
type Bit struct { Bits datastruct.Bits SetC color.RGBA // color returned when bit is set ClearC color.RGBA // color returned when bit is clear Stride int Thresh uint32 // threshold above which a bit is set in the RGB conversion Rect image.Rectangle }
Bit image uses a bit array to store data. The default colors assigned to bit values are color.White for set and color.Black for clear. These can be modified.
func (*Bit) ColorModel ¶
ColorModel implements the ColorModel function in the Image interface.
type Colorizer ¶
Colorizer uses the gray or red channel of an image to create an image tinted with a lerp'd gradient between two or more colors.
func NewColorizer ¶
func NewColorizer(img image.Image, c1, c2 color.Color, stops []int, colors []color.Color, post bool) *Colorizer
NewColorizer creates a new Colorizer and creates the internal lut. c1 and c2 are the colors at the start and end of the colorizer. The stops (in range [1,254] and colors values determine any intermediate points and can be nil. The post flag turns off the lerping between colors and yields a posterized image.
func (*Colorizer) ColorModel ¶
ColorModel implements the ColorModel function in the Image interface.
type Patch ¶
Patch is an infinite image covered with a patch of colors.
func (*Patch) ColorModel ¶
ColorModel implements the ColorModel function in the Image interface.
type Tile ¶
type Tile struct { TileImg *image.RGBA Width int Height int OffsX int OffsY int StagX int StagY int }
Tile is an infinite image covered with a tile.
func (*Tile) ColorModel ¶
ColorModel implements the ColorModel function in the Image interface.