imageutil

package module
v0.0.0-...-30d7a62 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2015 License: BSD-3-Clause Imports: 7 Imported by: 0

README

imagetools

GoDoc

imageutil is a Go package that contains a seemingly random collection of low-level image processing tools. While the tools have been developed for a specific purpose, they are shared in the hope that others will find them useful.

This package is (C) Victor Costan 2015, and made available under the MIT license, which is contained in the LICENSE file.

Documentation

Overview

Package imageutil is a collection of low-level image processing tools.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildRgbaMask

func BuildRgbaMask(rgba uint32) uint64

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

func HashForRgbaFindCrop(needle []byte, needleWidth int,
	needleHeight int) uint32

HashForRgbaFindCrop computes the needle hash needed by RgbaFind. It returns the hash.

func MaskRgba

func MaskRgba(rawImage []byte, mask uint64)

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

func ReadRgbaPng(fileName string) (*image.RGBA, error)

ReadRgbaPng decodes a PNG image from a file into a raw RGBA buffer. It returns the decoded image and any error encountered.

func RgbPixelToHsl

func RgbPixelToHsl(red int, green int, blue int) (int, int, int)

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

func RgbaToHsla(rgbaImage []byte, hslaImage []byte)

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.

func RgbaToPng

func RgbaToPng(rawImage []byte, width int, height int, fileName string) error

RgbaToPng encodes a raw RGBA-encoded image into a PNG image. It returns any error encountered.

Types

This section is empty.

Jump to

Keyboard shortcuts

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