imgproc

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

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

Go to latest
Published: Jun 1, 2017 License: MIT Imports: 7 Imported by: 0

README

imgproc

Build Status

GoLang package that provides simple image processing functions.

Use:

go get github.com/kelvins/imgproc

Functions:

  • IsGrayscale
  • ToGrayscale
  • ConvertImageToSlice
  • ResizeImage
  • SaveImage
  • LoadImage
  • LoadMultipleImages

Example:

import (
    "fmt"
    "log"
    "github.com/kelvins/imgproc"
)

img, err := imgproc.LoadImage("./face.png")
if err != nil {
    log.Fatal(err)
}

grayscaleImage := imgproc.ToGrayscale(img)

err = imgproc.SaveImage(grayscaleImage, "./face.png")
if err != nil {
    log.Fatal(err)
}

if imgproc.IsGrayscale(grayscaleImage) {
    fmt.Println("It is a grayscale image")
} else {
    fmt.Println("It is not a grayscale image")
}

imageSlice := imgproc.ConvertImageToSlice(grayscaleImage)

resizedImage, err = imgproc.ResizeImage(grayscaleImage, 100, 100)
if err != nil {
    log.Fatal(err)
}

Dependency:

It uses the imaging package to resize the image.

github.com/disintegration/imaging

Documentation

Overview

imgproc package that provides some simple and useful image processing functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertImageToSlice

func ConvertImageToSlice(img image.Image) []uint8

ConvertImageToSlice : convert the image to grayscale and then convert it to a integer slice.

func IsGrayscale

func IsGrayscale(img image.Image) bool

IsGrayscale : check if an image is in grayscale.

func LoadImage

func LoadImage(filePath string) (image.Image, error)

LoadImage : load an image file based on the file path.

func LoadMultipleImages

func LoadMultipleImages(paths []string) ([]image.Image, error)

LoadMultipleImages : load multiple images based on a slice of image paths.

func ResizeImage

func ResizeImage(img image.Image, width int, height int) (image.Image, error)

ResizeImage : resize the image based on the parameters (maximum size 10.000x10.000).

func SaveImage

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

SaveImage : save an image (Image) to an image file.

func ToGrayscale

func ToGrayscale(img image.Image) image.Image

ToGrayscale : convert an image to grayscale.

Types

This section is empty.

Jump to

Keyboard shortcuts

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