graphics

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2023 License: MIT Imports: 9 Imported by: 4

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

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

func Edgedetect(img image.Image) image.Image

Edgedetect detects edges in an image

func GrayAt added in v0.15.0

func GrayAt(img image.Image, x, y int) uint8

GrayAt returns the grayscale value of a pixel

func Grayscale added in v0.14.0

func Grayscale(img image.Image) image.Image

Grayscale converts an image to grayscale

func Invert added in v0.15.0

func Invert(img image.Image) (image.Image, error)

Invert inverts an image

func LoadImage added in v0.15.0

func LoadImage(filename string) image.Image

LoadImage loads an image from a file

func NearestNeighbor added in v0.14.0

func NearestNeighbor(img image.Image, newWidth, newHeight int) (*image.NRGBA, error)

NearestNeighbor resizes an image using the nearest neighbor algorithm

func ResizeNearestNeighbor

func ResizeNearestNeighbor(file *os.File, newWidth, newHeight int) (*image.NRGBA, error)

ResizeNearestNeighbor resizes an image using the nearest neighbor algorithm

func SaveImage added in v0.15.0

func SaveImage(img image.Image, filename string)

SaveImage saves an image to a file

func Threshold added in v0.15.0

func Threshold(img image.Image, threshold uint8) image.Image

Threshold thresholds an image

Types

This section is empty.

Jump to

Keyboard shortcuts

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