imagext

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2021 License: BSL-1.0 Imports: 7 Imported by: 0

README

imagext Package

GoDoc Go Report Card

About

This package provides functions for images. It's written for fast prototyping. Results may depend on format.

This Package is published on https://github.com/vbsw/imagext.

Copyright 2021, Vitali Baumtrok (vbsw@mailbox.org).

imagext Package is distributed under the Boost Software License, version 1.0. (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)

imagext Package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Boost Software License for more details.

Example

package main
import (
	"fmt"
	"github.com/vbsw/imagext"
)

func main() {
	imgColor := imagext.LoadImage("/home/alice/pictures/example.png")
	imgGray := imagext.NewGray(imgColor)
	err := imagext.SaveImage("/home/alice/pictures/example-gray.png", imgGray)
	if err != nil {
		fmt.Println(err.Error())
	}
}

References

Documentation

Overview

Package imagext provides functions for images. It's written for fast prototyping. Results may depend on format.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Gray

func Gray(r, g, b uint8) uint8

Gray converts values r (red), g (green) and b (blue) to a value of gray and returns it.

func LoadImage

func LoadImage(path string) image.Image

LoadImage reads image from file and returns it.

func NewGray

func NewGray(img image.Image) *image.Gray

NewGray converts argument img to a new image of grayscale and returns it. Result differes depending on image format.

func SaveImage

func SaveImage(path string, img image.Image) error

SaveImage saves image to file. Format is recognized from extension in path. Default is PNG.

func ToAvarage

func ToAvarage(img *image.Gray, size uint)

ToAvarage sets avarage values for each pixel in its area size*size, e.g. avarage value of {9, 5, 16} is 10.

func ToMedian

func ToMedian(img *image.Gray, size uint)

ToMedian sets median values for each pixel in its area size*size, e.g median value in {9, 5, 17} is 9.

func ToMonochrome

func ToMonochrome(img *image.Gray, threshold uint8)

ToMonochrome convertes image to black and white. Higher threshold means darker image.

Types

This section is empty.

Jump to

Keyboard shortcuts

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