imageutil

package module
v0.0.0-...-c367f39 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2016 License: Apache-2.0 Imports: 6 Imported by: 0

README

imageutil

GoDoc Build Status

Compossable utilities to facilitate (sometimes parallel) processing of images in Go. Also included are helpful – but opinionated – methods for common tasks.

*** Note: this library is coming together, but right now the API is in flux. ***

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AverageGray16

func AverageGray16(rect image.Rectangle, img Channel) color.Gray16

func AverageNRGBA64

func AverageNRGBA64(rect image.Rectangle, img *image.NRGBA64) color.NRGBA64

func ChannelsToNRGBA64

func ChannelsToNRGBA64(r, g, b, a Channel) *image.NRGBA64

func ColumnAverageGray16

func ColumnAverageGray16(radius int, img Channel) *image.Gray16

func ConvertToAlpha

func ConvertToAlpha(src ImageReader) *image.Alpha

ConvertToAlpha returns an *image.Alpha instance by asserting the given ImageReader has that type or, if it does not, using Copy to concurrently set the color.Color values of a new *image.Alpha instance with the same bounds.

func ConvertToAlpha16

func ConvertToAlpha16(src ImageReader) *image.Alpha16

ConvertToAlpha16 returns an *image.Alpha16 instance by asserting the given ImageReader has that type or, if it does not, using Copy to concurrently set the color.Color values of a new *image.Alpha16 instance with the same bounds.

func ConvertToGray

func ConvertToGray(src ImageReader) *image.Gray

ConvertToGray returns an *image.Gray instance by asserting the given ImageReader has that type or, if it does not, using Copy to concurrently set the color.Color values of a new *image.Gray instance with the same bounds.

func ConvertToGray16

func ConvertToGray16(src ImageReader) *image.Gray16

ConvertToGray16 returns an *image.Gray16 instance by asserting the given ImageReader has that type or, if it does not, using Copy to concurrently set the color.Color values of a new *image.Gray16 instance with the same bounds.

func ConvertToNRGBA

func ConvertToNRGBA(src ImageReader) *image.NRGBA

ConvertToNRGBA returns an *image.NRGBA instance by asserting the given ImageReader has that type or, if it does not, using Copy to concurrently set the color.Color values of a new *image.NRGBA instance with the same bounds.

func ConvertToNRGBA64

func ConvertToNRGBA64(src ImageReader) *image.NRGBA64

ConvertToNRGBA64 returns an *image.NRGBA64 instance by asserting the given ImageReader has that type or, if it does not, using Copy to concurrently set the color.Color values of a new *image.NRGBA64 instance with the same bounds.

func ConvertToRGBA

func ConvertToRGBA(src ImageReader) *image.RGBA

ConvertToRGBA returns an *image.RGBA instance by asserting the given ImageReader has that type or, if it does not, using Copy to concurrently set the color.Color values of a new *image.RGBA instance with the same bounds.

func ConvertToRGBA64

func ConvertToRGBA64(src ImageReader) *image.RGBA64

ConvertToRGBA64 returns an *image.RGBA64 instance by asserting the given ImageReader has that type or, if it does not, using Copy to concurrently set the color.Color values of a new *image.RGBA64 instance with the same bounds.

func Copy

func Copy(dst ImageReadWriter, src ImageReader)

Copy concurrently copies Color values from a source ImageReader to a destination ImageReadWriter.

func EdgesGray16

func EdgesGray16(radius int, img Channel) *image.Gray16

func EdgesNRGBA64

func EdgesNRGBA64(radius int, img *image.NRGBA64) *image.NRGBA64

func OpenImage

func OpenImage(name string) (image.Image, string, error)

OpenImage opens the named image file, decodes it, and closes it, returning an image and any error. BYO decoder support.

func RowAverageGray16

func RowAverageGray16(radius int, img Channel) *image.Gray16

Types

type Channel

type Channel interface {
	ImageReader
	Gray16At(x, y int) color.Gray16
}

Channel is any object that implements ImageReader as well as providing a method for getting color.Gray16 values at given coordinates. The standard library's image.Gray16 implements Channel.

func NRGBA64ToChannels

func NRGBA64ToChannels(img *image.NRGBA64) (r, g, b, a Channel)

Channels decomposes a given NRGBA64 into red, green, blue, and alpha Channels.

type ImageReadWriter

type ImageReadWriter interface {
	ImageReader
	ImageWriter
}

ImageReadWriter implements both ImageReader and ImageWriter.

type ImageReader

type ImageReader interface {
	At(x, y int) color.Color
	Bounds() image.Rectangle
	ColorModel() color.Model
}

ImageReader implements the same methods as the standard image interface.

func Invert

func Invert(img ImageReader) ImageReader

type ImageWriter

type ImageWriter interface {
	Set(x, y int, c color.Color)
}

ImageWriter implements a method for setting colors at individual coordinates (which all standard image types implement).

type PP

type PP func(image.Point)

PP is a point processor, any function that accepts a single image.Point value as an argument.

type RP

type RP func(image.Rectangle)

RP is a rectangle processor, any function that accepts a single image.Rectangle value as an argument.

func AllPointsRP

func AllPointsRP(pp PP) RP

AllPointsRP returns a RP that runs a given PP at every point within an input rectangle.

func ColumnsRP

func ColumnsRP(width int, rp RP) RP

ColumnsRP returns a RP that devides an input rectangle into columns of a given width and calls the provided RP on each. The last column proccessed will be any remainder and may not be of the given width.

func ConcurrentRP

func ConcurrentRP(w *sync.WaitGroup, rp RP) RP

ConcurrentRP wraps a given RP in a Go routine and the necessary WaitGroup operations to ensure that completion can be tracked.

func NColumnsRP

func NColumnsRP(n int, rp RP) RP

NColumnsRP calls the given RP on each of n vertical rectangles that span the input rectangle.

func NRectanglesRP

func NRectanglesRP(n int, rp RP) RP

NRectanglesRP calls the given RP on each of n horizontal or vertical rectangles that span the input rectangle.

func NRowsRP

func NRowsRP(n int, rp RP) RP

NRowsRP calls the given RP on each of n horizontal rectangles that span the input rectangle.

func PointsRP

func PointsRP(offset image.Point, strideH, strideV int, pp PP) RP

PointsRP returns a RP that runs a given PP at each point within an input rectangle starting at a given offset and seperated by the given horizontal and vertical stride.

func QuickColumnsRP

func QuickColumnsRP(rp RP) RP

QuickColumnsRP calls the given RP concurrently on each of GOMAXPROCS vertical rectangles that span the input rectangle.

func QuickRP

func QuickRP(rp RP) RP

QuickRP calls the given RP concurrently on each of GOMAXPROCS horizontal or vertical rectangles that span the input rectangle.

func QuickRowsRP

func QuickRowsRP(rp RP) RP

QuickRowsRP calls the given RP concurrently on each of GOMAXPROCS horizontal rectangles that span the input rectangle.

func RowsRP

func RowsRP(height int, rp RP) RP

RowsRP returns a RP that devides an input rectangle into rows of a given hight and calls the provided RP on each. The last row proccessed will be any remainder and may not be of the given height.

Jump to

Keyboard shortcuts

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