shist

package
v0.0.0-...-1b03cc8 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2023 License: MIT Imports: 6 Imported by: 2

Documentation

Overview

Package shist provides functions for computing a histogram of values of an image, and for computing and rendering a 2-dimensional histogram of values of a complex or ComplexInt32 gradient image.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GreyHist

func GreyHist(im SippImage) (hist []uint32)

GreyHist computes a 1D histogram of the greyscale values in the image.

Types

type BinPair

type BinPair struct {
	BinVal uint32
	Num    uint32
}

A BinPair hold the value of a histogram bin, and the number of times that value occurs in the histogram. That makes it a kind of histogram of a histogram.

type SippHist

type SippHist interface {
	// Grad returns the gradient image that this histogram is computed from.
	Grad() *ComplexImage
	// Size returns the width and height of the full histogram. ints are used
	// instead of uint32s for compatibility with native Go pixel indexing.
	Size() (int, int)
	// Max returns the maximum bin value that occurs in this histogram
	Max() uint32
	// Bins returns a compact slice of BinPairs for the histogram, without
	// duplicates. There is no order specified, but each call to Bins returns
	// the values in the same order.
	Bins() []BinPair
	// BinForPixel returns the index in the slice returned by Bins for the
	// given gradient-image pixel.
	BinForPixel(x, y int) int
	// Render returns a rendering of this histogram as an 8-bit image.  If clip
	// is true, values are clipped to 255. If clip is false, values are scaled
	// to 255.
	Render(clip bool) SippImage
	// RenderSuppressed renders a suppressed version of the histogram and returns
	// the result as an 8-bit grayscale image. "Suppressed" here means that the
	// bin value is scaled by the ratio of the distance of the bin from 0 over
	// the maximum distance. Hence the centre is reduced to 0, the maximum
	// value remains unmodified, and all values in between will be scaled
	// linearly between them.
	RenderSuppressed() SippImage
	// RenderSubstitute renders an 8-bit image of the histogram, substituting
	// the given value as the pixel value for each corresponding bin value. The
	// input slice must be the same length as the slice of bin values returned
	// by Bins, and contain new values corresponding to that order.
	// Note that as the slice returned by Bins() does not include 0 values,
	// the value to be used for empty bins must be supplied.
	// This is used to render point transforms of the histogram, such as the
	// delentropy values.
	RenderSubstitute(subs []uint8, zeroVal uint8) SippImage
}

A SippHist is a 2D histogram.

func Hist

func Hist(grad *ComplexImage) (hist SippHist)

Hist computes the 2D histogram from the given gradient image.

Jump to

Keyboard shortcuts

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