Documentation ¶
Overview ¶
manipulating images pixel by pixel
Example ¶
package main import ( "simonwaldherr.de/go/golibs/graphics" ) func main() { img := graphics.LoadImage("img.jpg") img_gray := graphics.Grayscale(img) img_rnn, _ := graphics.NearestNeighbor(img, 80, 24) img_each, _ := graphics.EachPixelOfImage(img, func(r, g, b, a uint8) (uint8, uint8, uint8, uint8) { return g, b, r, a }) img_edge := graphics.Edgedetect(img) img_invert, _ := graphics.Invert(img) img_threshold := graphics.Threshold(img, 128) graphics.SaveImage(img_gray, "img_gray.png") graphics.SaveImage(img_rnn, "img_rnn.png") graphics.SaveImage(img_each, "img_each.png") graphics.SaveImage(img_edge, "img_edge.png") graphics.SaveImage(img_invert, "img_invert.png") graphics.SaveImage(img_threshold, "img_threshold.png") }
Output:
Index ¶
- func EachPixel(file *os.File, f func(uint8, uint8, uint8, uint8) (uint8, uint8, uint8, uint8)) (image.Image, error)
- func EachPixelOfImage(src image.Image, ...) (image.Image, error)
- func Edgedetect(img image.Image) image.Image
- func GrayAt(img image.Image, x, y int) uint8
- func Grayscale(img image.Image) image.Image
- func Invert(img image.Image) (image.Image, error)
- func LoadImage(filename string) image.Image
- func NearestNeighbor(img image.Image, newWidth, newHeight int) (*image.NRGBA, error)
- func ResizeNearestNeighbor(file *os.File, newWidth, newHeight int) (*image.NRGBA, error)
- func SaveImage(img image.Image, filename string)
- func Threshold(img image.Image, threshold uint8) image.Image
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EachPixel ¶
func EachPixel(file *os.File, f func(uint8, uint8, uint8, uint8) (uint8, uint8, uint8, uint8)) (image.Image, error)
EachPixel applies a function to each pixel of an image
func EachPixelOfImage ¶ added in v0.15.0
func EachPixelOfImage(src image.Image, f func(uint8, uint8, uint8, uint8) (uint8, uint8, uint8, uint8)) (image.Image, error)
EachPixelOfImage applies a function to each pixel of an image
func Edgedetect ¶ added in v0.14.0
Edgedetect detects edges in an image
func NearestNeighbor ¶ added in v0.14.0
NearestNeighbor resizes an image using the nearest neighbor algorithm
func ResizeNearestNeighbor ¶
ResizeNearestNeighbor resizes an image using the nearest neighbor algorithm
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.