mblur

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

README

GoDoc

mblur

Motion blur adapted from ImageMagick, but without any kind of performance optimization.

%  MotionBlurImage() simulates motion blur.  We convolve the image with a
%  Gaussian operator of the given radius and standard deviation (sigma).
%  For reasonable results, radius should be larger than sigma.  Use a
%  radius of 0 and MotionBlurImage() selects a suitable radius for you.
%  Angle gives the angle of the blurring motion.
%
%  Andrew Protano contributed this effect.
%
%  The format of the MotionBlurImage method is:
%
%    Image *MotionBlurImage(const Image *image,const double radius,
%      const double sigma,const double angle,ExceptionInfo *exception)
%
%  A description of each parameter follows:
%
%    o image: the image.
%
%    o radius: the radius of the Gaussian, in pixels, not counting
%      the center pixel.
%
%    o sigma: the standard deviation of the Gaussian, in pixels.
%
%    o angle: Apply the effect along this angle.

Documentation

Index

Constants

View Source
const (
	MagickEpsilon = 1.0e-12
	MagickSQ2PI   = 2.50662827463100024161235523934010416269302368164062
	QuantumRange  = float64(18446744073709551615.0)
	QuantumScale  = 1 / QuantumRange
)

Variables

This section is empty.

Functions

func CloneImage

func CloneImage(img image.Image) draw.Image

CloneImage simply copies the given image in a new image.NRGBA

func DegreesToRadians

func DegreesToRadians(deg float64) float64

func GetOptimalKernelWidth1D

func GetOptimalKernelWidth1D(radius, sigma float64) int

GetOptimalKernelWidth1D computes the optimal kernel radius for a convolution filter. Start with the minimum value of 3 pixels and walk out until we drop below the threshold of one pixel numerical accuracy.

func MotionBlurImage

func MotionBlurImage(img image.Image, radius, sigma, angle float64) image.Image

MotionBlurImage simulates motion blur. We convolve the image with a Gaussian operator of the given radius and standard deviation (sigma). For reasonable results, radius should be larger than sigma. Use a radius of 0 and MotionBlurImage() selects a suitable radius for you. Angle gives the angle of the blurring motion.

func PerceptibleReciprocal

func PerceptibleReciprocal(x float64) float64

PerceptibleReciprocal returns 1/x where x is perceptible (not unlimited or infinitesimal).

Types

type Kernel1D added in v1.0.1

type Kernel1D []float64

func (Kernel1D) Apply added in v1.0.1

func (kernel Kernel1D) Apply(img image.Image, angle float64) image.Image

func (Kernel1D) Normalize added in v1.0.1

func (k Kernel1D) Normalize() Normalized1DKernel

type Normalized1DKernel added in v1.0.1

type Normalized1DKernel []float64

func MotionBlurKernel added in v1.0.1

func MotionBlurKernel(radius, sigma float64) Normalized1DKernel

MotionBlurKernel returns a kernel for a given type of motion blur, and might help make things slightly faster if using the same motion blur radius/sigma on multiple images

func (Normalized1DKernel) Apply added in v1.0.1

func (kernel Normalized1DKernel) Apply(img image.Image, angle float64) image.Image

type PointInfo

type PointInfo struct {
	X, Y float64
}

Jump to

Keyboard shortcuts

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