imgd

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: BSD-3-Clause Imports: 11 Imported by: 0

README

Gosl. ml/imgd. Machine Learning: Functions to Handle Images

go.dev reference

More information is available in the documentation of this package.

This package contains some functions and structures to assists on Machine Learning works involving images.

  • Sample holds image data (e.g. pixel intensities)
  • Board holds a collection of Samples for displaying purposes

TODO

  • Implement color versions of Sample and Board
  • Add more tests
  • Add benchmarks

Documentation

Overview

Package imgd (image-data) adds functionality to process image-data, e.g. for pattern recognition using images.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGrayImage

func GetGrayImage(width, height, pad int) (img *image.Gray)

GetGrayImage returns a gray image object

func SavePng

func SavePng(outdir, fnameKey string, img image.Image)

SavePng saves png figure

Types

type GrayBoard

type GrayBoard struct {
	// contains filtered or unexported fields
}

GrayBoard holds grayscale figure data

func NewGrayBoard

func NewGrayBoard(numSamples, largestSampleWidth, largestSampleHeight, padding int) (o *GrayBoard)

NewGrayBoard returns a new board to display samples

func (*GrayBoard) DrawBin

func (o *GrayBoard) DrawBin(x, y int)

DrawBin draws rectangle indicating sample spot

func (*GrayBoard) NumBins

func (o *GrayBoard) NumBins() int

NumBins returns the computed total number of bins/spots/places in board; i.e. nrow * ncol

func (*GrayBoard) Paint

func (o *GrayBoard) Paint(samples GraySamples, smin, smax float64, drawBins bool)

Paint paints board

func (*GrayBoard) SavePng

func (o *GrayBoard) SavePng(outdir, fnameKey string)

SavePng saves png figure

type GraySample

type GraySample struct {
	// contains filtered or unexported fields
}

GraySample holds sample data corresponding go grayscale images

func NewGraySample

func NewGraySample(idx, size int, X *la.Matrix, rowMaj bool) (o *GraySample)

NewGraySample returns a new sample data

idx    -- position in X matrix
size   -- total number of pixels = width*height
X      -- matrix with all pixel data (intensity of gray)
rowMaj -- data is stored as a row-major matrix instead of col-major

func (*GraySample) GetImage

func (o *GraySample) GetImage(pad int) (img *image.Gray)

GetImage returns an image object sized to this sample

func (*GraySample) Paint

func (o *GraySample) Paint(img *image.Gray, x0, y0 int, smin, smax float64)

Paint paints sample into img

x0   -- horizontal shift in img
y0   -- vertical shift in img
smin -- minimum gray intensity for normalization
smax -- minimum gray intensity for normalization

type GraySamples

type GraySamples []*GraySample

GraySamples holds a set of gray sample data

func NewGraySamples

func NewGraySamples(X *la.Matrix, nSelected int, rowMaj, random bool) (selected GraySamples)

NewGraySamples returns a set of randomly selected samples

func (*GraySamples) Stat

func (o *GraySamples) Stat() (smin, smax float64, maxWidth, maxHeight int)

Stat returns some statistics about all samples smin and smax are the min and max intensities

Jump to

Keyboard shortcuts

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