Documentation ¶
Overview ¶
Package imageutil is a collection of low-level image processing tools.
Index ¶
- func BuildRgbaMask(rgba uint32) uint64
- func CropRgba(rawImage []byte, width int, height int, xOffset int, yOffset int, xSize int, ...)
- func HashForRgbaFindCrop(needle []byte, needleWidth int, needleHeight int) uint32
- func MaskRgba(rawImage []byte, mask uint64)
- func ReadRgbaPng(fileName string) (*image.RGBA, error)
- func RgbPixelToHsl(red int, green int, blue int) (int, int, int)
- func RgbaCheckCrop(haystack []byte, hayWidth int, hayHeight int, needle []byte, needleWidth int, ...) bool
- func RgbaCheckMaskedCrop(haystack []byte, hayWidth int, hayHeight int, needle []byte, needleWidth int, ...) bool
- func RgbaDiffMaskedCrop(haystack []byte, hayWidth int, hayHeight int, needle []byte, needleWidth int, ...) int64
- func RgbaDiffThresholdCrop(haystack []byte, hayWidth int, hayHeight int, needle []byte, needleWidth int, ...) int
- func RgbaFindCrop(haystack []byte, hayWidth int, hayHeight int, needle []byte, needleWidth int, ...) (int, int, int)
- func RgbaFindMaskedCrop(haystack []byte, hayWidth int, hayHeight int, needle []byte, needleWidth int, ...) (int, int, int)
- func RgbaFindPillars(rgbaImage []byte, width int, height int, minRed int, maxRed int, minGreen int, ...)
- func RgbaFindPuddle(rgbaImage []byte, width int, height int, minRed int, maxRed int, minGreen int, ...) int
- func RgbaResetPuddles(rgbaImage []byte)
- func RgbaThreshold(rgbaImage []byte, minRed int, maxRed int, minGreen int, maxGreen int, ...)
- func RgbaToHsla(rgbaImage []byte, hslaImage []byte)
- func RgbaToPng(rawImage []byte, width int, height int, fileName string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BuildRgbaMask ¶
BuildMask computes a word mask from a 32-bit RGBA mask. The word mask is intended to be used with the MaskRgba function.
func CropRgba ¶
func CropRgba(rawImage []byte, width int, height int, xOffset int, yOffset int, xSize int, ySize int, target *[]byte)
CropRgba crops an RGBA image into a target slice. The target slice's length is set to the needed image length. If the slice's capacity is too small, the slice is re-created.
func HashForRgbaFindCrop ¶
HashForRgbaFindCrop computes the needle hash needed by RgbaFind. It returns the hash.
func MaskRgba ¶
MaskRgba applies a word mask to an RGBA image buffer. This uses fast 64-bit operations. In return for the speed, the caller must covert the RGBA mask into a word mask, with the help of BuildMask.
func ReadRgbaPng ¶
ReadRgbaPng decodes a PNG image from a file into a raw RGBA buffer. It returns the decoded image and any error encountered.
func RgbPixelToHsl ¶
RgbPixelToHsl returns the HSL values for a RGB color with 8-bits / channel. It is mostly useful for easy conversion to our custom HSL scheme where H is scaled between 0 and 255.
func RgbaCheckCrop ¶
func RgbaCheckCrop(haystack []byte, hayWidth int, hayHeight int, needle []byte, needleWidth int, needleHeight int, needleLeft int, needleTop int) bool
RgbaCheckCrop returns true if an image is a cropped version of another one. This is image pattern-matching, but only aligns the pattern with the image in one predetermined position.
func RgbaCheckMaskedCrop ¶
func RgbaCheckMaskedCrop(haystack []byte, hayWidth int, hayHeight int, needle []byte, needleWidth int, needleHeight int, needleLeft int, needleTop int, rgbaMask uint32) bool
RgbaCheckMaskedCrop checks if an image is a crop&mask from another image. This is image pattern-matching, but only aligns the pattern with the image in one predetermined position, and masks the image on the fly. The pattern is assumed to have already been masked.
func RgbaDiffMaskedCrop ¶
func RgbaDiffMaskedCrop(haystack []byte, hayWidth int, hayHeight int, needle []byte, needleWidth int, needleHeight int, needleLeft int, needleTop int, rgbaMask uint32) int64
RgbaDiffMaskedCrop diffs an image with a crop&mask of another image. It returns the sum of absolute pixel differences.
func RgbaDiffThresholdCrop ¶
func RgbaDiffThresholdCrop(haystack []byte, hayWidth int, hayHeight int, needle []byte, needleWidth int, needleHeight int, needleLeft int, needleTop int, minRed int, maxRed int, minGreen int, maxGreen int, minBlue int, maxBlue int) int
RgbaDiffThresholdCrop diffs an image with a crop&threshold of another image. It returns the sum of absolute pixel differences.
func RgbaFindCrop ¶
func RgbaFindCrop(haystack []byte, hayWidth int, hayHeight int, needle []byte, needleWidth int, needleHeight int, needleHash uint32, scratch []byte) (int, int, int)
RgbaFindCrop looks for a needle image in a hastack image. It returns the number of matches and the coordinates of the last match. The scratch space capacity must be at least 4 * hayWidth. The needle's hash can be computed by RgbaHashForFindCrop.
func RgbaFindMaskedCrop ¶
func RgbaFindMaskedCrop(haystack []byte, hayWidth int, hayHeight int, needle []byte, needleWidth int, needleHeight int, rgbaMask uint32, needleHash uint32, scratch []byte) (int, int, int)
RgbaFindMaskedCrop looks for a masked needle image in a hastack image. It returns the number of matches and the coordinates of the last match. The scratch space capacity must be at least 4 * hayWidth. The needle's hash can be computed by RgbaHashForFindCrop. The needle is assumed to have been masked before RgbaHashForFindCrop and this method are called.
func RgbaFindPillars ¶
func RgbaFindPillars(rgbaImage []byte, width int, height int, minRed int, maxRed int, minGreen int, maxGreen int, minBlue int, maxBlue int, pillars [][4]int32)
RgbaFindPillars returns the tallest vertical strips in an image.
func RgbaFindPuddle ¶
func RgbaFindPuddle(rgbaImage []byte, width int, height int, minRed int, maxRed int, minGreen int, maxGreen int, minBlue int, maxBlue int, startY int, puddlePixels [][2]int32) int
RgbaFindPuddle locates contiguous areas in an image. The image's A channel is (ab)used to track the image's visited areas. It returns the size of the area that it found.
func RgbaResetPuddles ¶
func RgbaResetPuddles(rgbaImage []byte)
RgbaResetPuddles resets the Alpha channel of all pixles to 255. This is useful after running puddle searches over an image.
func RgbaThreshold ¶
func RgbaThreshold(rgbaImage []byte, minRed int, maxRed int, minGreen int, maxGreen int, minBlue int, maxBlue int)
RgbaThreshold sets the alpha channel in image to a threshold function. The function is 1 when the R, G, and B values are between given amounts, and 0 otherwise.
func RgbaToHsla ¶
RgbaToHsla converts an RGBA image to a HSLA image. H, S, and L are in the range 0..255. A is unchanged. HSLA images can be used with most RGBA processing functions, like RgbaToPng.
Types ¶
This section is empty.