blurry

package module
v1.20.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: MIT Imports: 9 Imported by: 0

README

blurry

MIT License GoDoc Go Report Card Releases

fast, high peformance image processing libary.

blurry provides image processing algorithms with halide-lang backend.
implements optimized processor for amd64 CPUs on Linux/macos

Benchmarks

Halide JIT benchmarks

This is the result of using halide's benchamrk.
darwin/amd64 Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz

src 320x240
BenchmarkJIT/cloneimg                      : 0.00788ms
BenchmarkJIT/convert_from_argb             : 0.02375ms
BenchmarkJIT/convert_from_abgr             : 0.03884ms
BenchmarkJIT/convert_from_bgra             : 0.02470ms
BenchmarkJIT/convert_from_rabg             : 0.03655ms
BenchmarkJIT/convert_from_yuv_420          : 0.03168ms
BenchmarkJIT/convert_from_yuv_444          : 0.02686ms
BenchmarkJIT/convert_to_yuv_420            : 0.06742ms
BenchmarkJIT/convert_to_yuv_444            : 0.07209ms
BenchmarkJIT/rotate0                       : 0.00774ms
BenchmarkJIT/rotate90                      : 0.02599ms
BenchmarkJIT/rotate180                     : 0.00802ms
BenchmarkJIT/rotate270                     : 0.02582ms
BenchmarkJIT/crop                          : 0.06126ms
BenchmarkJIT/scale                         : 0.13889ms
BenchmarkJIT/scale_box                     : 0.20598ms
BenchmarkJIT/scale_linear                  : 0.20440ms
BenchmarkJIT/scale_gaussian                : 0.31444ms
BenchmarkJIT/blend_normal                  : 0.08443ms
BenchmarkJIT/blend_sub                     : 0.08398ms
BenchmarkJIT/blend_add                     : 0.08364ms
BenchmarkJIT/blend_diff                    : 0.08453ms
BenchmarkJIT/grayscale                     : 0.03687ms
BenchmarkJIT/invert                        : 0.03730ms
BenchmarkJIT/brightness                    : 0.04703ms
BenchmarkJIT/gammacorrection               : 0.08013ms
BenchmarkJIT/contrast                      : 0.01549ms
BenchmarkJIT/boxblur                       : 0.11211ms
BenchmarkJIT/gaussianblur                  : 0.33058ms
BenchmarkJIT/blockmozaic                   : 0.27455ms
BenchmarkJIT/erosion                       : 0.11934ms
BenchmarkJIT/dilation                      : 0.12013ms
BenchmarkJIT/morphology_open               : 0.10370ms
BenchmarkJIT/morphology_close              : 0.10435ms
BenchmarkJIT/morphology_gradient           : 0.07684ms
BenchmarkJIT/emboss                        : 0.04402ms
BenchmarkJIT/laplacian                     : 0.03192ms
BenchmarkJIT/highpass                      : 0.03847ms
BenchmarkJIT/gradient                      : 0.03322ms
BenchmarkJIT/edgedetect                    : 0.02705ms
BenchmarkJIT/sobel                         : 0.06276ms
BenchmarkJIT/canny                         : 0.29922ms
BenchmarkJIT/canny_dilate                  : 0.35114ms
BenchmarkJIT/canny_morphology_open         : 0.44488ms
BenchmarkJIT/canny_morphology_close        : 0.40522ms
BenchmarkJIT/match_template_sad            : 5.75482ms
BenchmarkJIT/match_template_ssd            : 4.48363ms
BenchmarkJIT/match_template_ncc            : 8.32420ms
BenchmarkJIT/prepared_match_template_ncc   : 6.22423ms
BenchmarkJIT/match_template_zncc           : 12.73780ms
BenchmarkJIT/prepared_match_template_zncc  : 11.38906ms
BenchmarkJIT/pcm16_decibel                 : 0.00257ms

AOT benchmarks

Calling a library compiled by AOT(ahead-of-time) via cgo.
In cgo, due to the overhead of ffi calls(e.g.), more complex operations will be optimized for CPU and become faster.
Also, the execution speed may be reduced by the overhead of multiple calls.

Blur

/D is DisablePool, i.e. the benchmark when BufferPool is off.

graph

goos: darwin
goarch: amd64
pkg: github.com/octu0/blurry/benchmark
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
BenchmarkBlur
BenchmarkBlur/bild/blur/Box
BenchmarkBlur/bild/blur/Box-8         	     154	   7812824 ns/op	  640402 B/op	      11 allocs/op
BenchmarkBlur/bild/blur/Gaussian
BenchmarkBlur/bild/blur/Gaussian-8    	     333	   3486751 ns/op	 1262485 B/op	      21 allocs/op
BenchmarkBlur/imaging/Blur
BenchmarkBlur/imaging/Blur-8          	     786	   1520193 ns/op	  793698 B/op	      45 allocs/op
BenchmarkBlur/stackblur-go
BenchmarkBlur/stackblur-go-8          	     231	   5147219 ns/op	  925937 B/op	  153609 allocs/op
BenchmarkBlur/libyuv/ARGBBlur
BenchmarkBlur/libyuv/ARGBBlur-8       	    1861	    642486 ns/op	10182722 B/op	       3 allocs/op
BenchmarkBlur/blurry/Boxblur
BenchmarkBlur/blurry/Boxblur-8        	    7257	    178086 ns/op	      88 B/op	       2 allocs/op
BenchmarkBlur/blurry/Gaussianblur
BenchmarkBlur/blurry/Gaussianblur-8   	    5367	    222615 ns/op	     146 B/op	       2 allocs/op
BenchmarkBlur/blurry/Boxblur/D
BenchmarkBlur/blurry/Boxblur/D-8      	    6093	    201573 ns/op	  311361 B/op	       2 allocs/op
BenchmarkBlur/blurry/Gaussianblur/D
BenchmarkBlur/blurry/Gaussianblur/D-8 	    4629	    257483 ns/op	  311361 B/op	       2 allocs/op
Edge

graph

goos: darwin
goarch: amd64
pkg: github.com/octu0/blurry/benchmark
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
BenchmarkEdge
BenchmarkEdge/bild/EdgeDetection
BenchmarkEdge/bild/EdgeDetection-8         	     643	   1858350 ns/op	  631257 B/op	      10 allocs/op
BenchmarkEdge/blurry/Edge
BenchmarkEdge/blurry/Edge-8                	   10000	    100695 ns/op	  311513 B/op	       3 allocs/op
Rotate

graph

goos: darwin
goarch: amd64
pkg: github.com/octu0/blurry/benchmark
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
BenchmarkRotate
BenchmarkRotate/bild/Rotate/90
BenchmarkRotate/bild/Rotate/90-8         	     612	   2080543 ns/op	 1237046 B/op	  115685 allocs/op
BenchmarkRotate/bild/Rotate/180
BenchmarkRotate/bild/Rotate/180-8        	     480	   2355424 ns/op	 1540311 B/op	  153605 allocs/op
BenchmarkRotate/bild/Rotate/270
BenchmarkRotate/bild/Rotate/270-8        	     520	   2061518 ns/op	 1236932 B/op	  115685 allocs/op
BenchmarkRotate/imaging/90
BenchmarkRotate/imaging/90-8             	    7918	    130736 ns/op	  314181 B/op	       6 allocs/op
BenchmarkRotate/imaging/180
BenchmarkRotate/imaging/180-8            	    9654	    138252 ns/op	  313542 B/op	       6 allocs/op
BenchmarkRotate/imaging/270
BenchmarkRotate/imaging/270-8            	    6972	    163349 ns/op	  314165 B/op	       6 allocs/op
BenchmarkRotate/libyuv/ARGBRotate/90
BenchmarkRotate/libyuv/ARGBRotate/90-8   	   13423	     81131 ns/op	  311360 B/op	       2 allocs/op
BenchmarkRotate/libyuv/ARGBRotate/180
BenchmarkRotate/libyuv/ARGBRotate/180-8  	   34771	     34425 ns/op	  311361 B/op	       2 allocs/op
BenchmarkRotate/libyuv/ARGBRotate/270
BenchmarkRotate/libyuv/ARGBRotate/270-8  	   15904	     78290 ns/op	  311361 B/op	       2 allocs/op
BenchmarkRotate/blurry/Rotate/90
BenchmarkRotate/blurry/Rotate/90-8       	   10000	    109336 ns/op	  311514 B/op	       3 allocs/op
BenchmarkRotate/blurry/Rotate/180
BenchmarkRotate/blurry/Rotate/180-8      	   13102	     89067 ns/op	  311514 B/op	       3 allocs/op
BenchmarkRotate/blurry/Rotate/270
BenchmarkRotate/blurry/Rotate/270-8      	   10000	    124949 ns/op	  311514 B/op	       3 allocs/op
Sobel

graph

goos: darwin
goarch: amd64
pkg: github.com/octu0/blurry/benchmark
cpu: Intel(R) Core(TM) i7-8569U CPU @ 2.80GHz
BenchmarkSobel
BenchmarkSobel/bild/Sobel
BenchmarkSobel/bild/Sobel-8         	     208	   5707148 ns/op	 2196784 B/op	      32 allocs/op
BenchmarkSobel/libyuv/ARGBSobel
BenchmarkSobel/libyuv/ARGBSobel-8   	   16557	     72320 ns/op	  311361 B/op	       2 allocs/op
BenchmarkSobel/blurry/Sobel
BenchmarkSobel/blurry/Sobel-8       	    9255	    140586 ns/op	  311515 B/op	       3 allocs/op
Other Benchmarks

See _benchmark for benchmarks of other methods and performance comparison with libyuv.

Installation

$ go get github.com/octu0/blurry

Examples

original image

original

Rotate

rotation 0/90/180/270 clockwise

img, err := blurry.Rotate(input, blurry.Rotate90)
blurry.RotationMode Result
blurry.Rotate90 example
blurry.Rotate180 example
blurry.Rotate270 example
Flip

flipV(vertically) flipH(horizontally)

img, err := blurry.Flip(input, blurry.FlipVertical)
blurry.FlipMode Result
blurry.FlipVertical example
blurry.FlipHorizon example
Crop

crop x,y with crop_width,crop_height

img, err := blurry.Crop(input, image.Pt(175, 40), crop_width, crop_height)
original x=175,y=40,cw=80,ch=50
original cropped
Scale

a.k.a. Resize resampling

img, err := blurry.Scale(input, scale_width, scale_height, blurry.ScaleFilterNone)
blurry.ScaleFilter Result
blurry.ScaleFilterNone example
blurry.ScaleFilterBox example
blurry.ScaleFilterLinear example
blurry.ScaleFilterGaussian example
Grayscale
img, err := blurry.Grayscale(input)

example

Invert
img, err := blurry.Invert(input)

example

Brightness
img, err := blurry.Brightness(input, 1.5)

example

Gamma
img, err := blurry.Gamma(input, 2.5)

example

Contrast
img, err := blurry.Contrast(input, 0.525)

example

BoxBlur
img, err := blurry.Boxblur(input, 11)

example

GaussianBlur
img, err := blurry.Gaussianblur(input, 5.0)

example

BlockMozaic
img, err := blurry.Blockmozaic(input, 10)

example

Erode
img, err := blurry.Erosion(input, 5)

example

Dilate
img, err := blurry.Dilation(input, 8)

example

Morphology

Morphology repeats Erode and Dilate N times.

size := 5
N := 2
img, err := blurry.Morphology(input, MorphOpen, size, N)
blurry.MorphologyMode Result
blurry.MorphologyOpen example
blurry.MorphologyClose example
blurry.MorphologyGradient example
Emboss
img, err := blurry.Emboss(input)

example

HighPass
img, err := blurry.Highpass(input)

example

Laplacian
img, err := blurry.Laplacian(input)

example

Gradient
img, err := blurry.Gradient(input)

example

Edge

a.k.a. Edge Detection

img, err := blurry.Edge(input)

example

Sobel
img, err := blurry.Sobel(input)

example

Canny

a.k.a. Canny Edge Detection

img, err := blurry.Canny(input, 250, 100)
max:250 min:100 max:400 min:10
example example2
Canny with Dilate
img, err := blurry.CannyWithDilate(input, 250, 100, 3)
max:250 min:100 dilate:3 max:250 min:150 dilate:4
example example2
Morphology Canny with Dilate

Pre-process morphology before applying Canny process.

mode := blurry.CannyMorphologyClose
morph_size := 5
dilate_size := 3
img, err := blurry.MorphologyCannyWithDilate(input, 250, 100, mode, morph_size, dilate_size);
blurry.CannyMorphologyMode Result
blurry.CannyMorphologyOpen example
blurry.CannyMorphologyClose example
Template Matching

SAD(Sum of Absolute Difference), SSD(Sum of Squared Difference), NCC(Normalized Cross Correlation) AND ZNCC(Zero means Normalized Cross Correlation) methods are available for template matching.

SAD
scores, err := blurry.MatchTemplateSAD(input, template, 1000)
filter input template Result
none example example example
grayscale example example example
sobel example example example
canny dilate:3 morph:open example example example
SSD
scores, err := blurry.MatchTemplateSSD(input, template, 1000)
filter input template Result
none example example example
grayscale example example example
sobel example example example
canny dilate:3 morph:open example example example
NCC
scores, err := blurry.MatchTemplateNCC(input, template, 0.1)
filter input template Result
none example example example
grayscale example example example
sobel example example example
canny dilate:3 morph:open example example example
Prepared NCC

Improve processing speed by pre-calculating part of NCC process.

p, err := blurry.PrepareNCCTemplate(template)
if err != nil {
  panic(err)
}
defer blurry.FreePreparedNCCTemplate(p)

for _, img := range images {
  scores, err := blurry.PreparedMatchTemplateNCC(img, p, 0.1)
  if err != nil {
    panic(err)
  }
}
ZNCC
scores, err := blurry.MatchTemplateZNCC(input, template, 0.1)
filter input template Result
none example example example
grayscale example example example
sobel example example example
canny dilate:3 morph:open example example example
Prepared ZNCC

Improve processing speed by pre-calculating part of ZNCC process.

p, err := blurry.PrepareZNCCTemplate(template)
if err != nil {
  panic(err)
}
defer blurry.FreePreparedZNCCTemplate(p)

for _, img := range images {
  scores, err := blurry.PreparedMatchTemplateZNCC(img, p, 0.1)
  if err != nil {
    panic(err)
  }
}
Contour

Extract contours based on the sobel filter for binarization.
In actual use, it is better to denoise the image before passing it through the sobel filter.

points, err := blurry.Contour(input, 100, 4)
threshold size Result
100 4 example
150 4 example
200 4 example
250 4 example
100 2 example
200 2 example
Blend

Blend input1 on input0.

img, err := blurry.Blend(input0, input1, image.Pt(76, 36), blurry.BlendNormal)
blurry.BlendMode Result
blurry.BlendNormal example
blurry.BlendSub example
blurry.BlendAdd example
blurry.BlendDiff example
Convert

blurry supports reading ARGB, ABGR, BGRA, YUV420 and YUV444.
It also supports YUV444 output.

Read: RGBA Color Model
img, err := blurry.ConvertFromARGB(input)
ColorModel Method
ARGB blurry.ConvertFromARGB(*image.RGBA)
ABGR blurry.ConvertFromABGR(*image.RGBA)
BGRA blurry.ConvertFromBGRA(*image.RGBA)
RABG blurry.ConvertFromRABG(*image.RGBA)
Read: YUV Chroma Subsampling
img, err := blurry.ConvertFromYUV420(ycbcr)
Subsampling Method
420 blurry.ConvertFromYUV420(*image.YCbCr)
444 blurry.ConvertFromYUV444(*image.YCbCr)

or byte slice can also be specified

var y,u,v []byte
var strideY,strideU,strideV int
var width, height int

img, err := blurry.ConvertFromYUV420Plane(y, u, v, strideY, strideU, strideV, width, height)
Subsampling Method
420 blurry.ConvertFromYUV420Plane(y,u,v []byte, int,int,int, w,h int)
444 blurry.ConvertFromYUV444Plane(y,u,v []byte, int,int,int, w,h int)
Write: YUV Chroma Subsampling
ycbcr, err := blurry.ConvertToYUV444(rgba)
Subsampling Method
420 blurry.ConvertToYUV420(*image.RGBA)
444 blurry.ConvertToYUV444(*image.RGBA)
PCM16 Decibel

Gets the decibel of given PCM16.

var data []byte
decibel, err := blurry.PCM16Decibel(data, length)

or

var input []int16
decibel, err := blurry.PCM16DecibelFromInt16(input)

CLI usage

Run it via docker.
Use docker run -v to specify where to load the images and where to output them (/tmp will be used as a temporary file).

$ mkdir myimagedir
$ mkdir myimageout
$ cp /from/img/path.png myimagedir/src.png

# grayscale
$ docker run --rm -it \
  -v $PWD/myimagedir:/img \
  -v $PWD/myimageout:/tmp \
  blurry:1.0.0 grayscale -i /img/src.png
Help
NAME:
   blurry

USAGE:
   blurry [global options] command [command options] [arguments...]

VERSION:
   1.20.1

COMMANDS:
     blend             
     blockmozaic       
     boxblur           
     brightness        
     canny             
     clone             
     contour           
     contrast          
     convert           
     convert_from_yuv  
     convert_to_yuv    
     crop              
     dilation          
     edge              
     emboss            
     erosion           
     flip              
     gamma             
     gaussianblur      
     gradient          
     grayscale         
     highpass          
     invert            
     laplacian         
     morphology        
     match_template    
     pcm16             
     rotate            
     scale             
     sobel             
     help, h           Shows a list of commands or help for one command

GLOBAL OPTIONS:
   --debug, -d    debug mode
   --verbose, -V  verbose. more message
   --help, -h     show help
   --version, -v  print the version

Build

When building, create a docker container with Halide(clang, llvm, etc). installed as the build environment.

$ make build-generator

Compile libruntime.a and all kinds lib*_osx.a or lib*_linu.a to make static link.

$ make generate

Finally, generate a docker image if necessary.

$ make build

Develop

Set up configuration for macos to be able to run image filtering directly through Halide.

setup Halide on local

$ make setup-halide-runtime

generate and run

genrun package allows you to export images to temporary file and run image filtering directly.

$ go run cmd/genrun/main.go benchmark

License

MIT, see LICENSE file for details.

Documentation

Index

Constants

View Source
const (
	AppName string = "blurry"
	Version string = "1.20.2"
)
View Source
const (
	RGBAStride int = 4
)

Variables

View Source
var (
	ErrConvertFromYUV           = errors.New("convert_from cgo call error")
	ErrConvertToYUV             = errors.New("convert_to cgo call error")
	ErrYUVSubsampleRateMustI420 = errors.New("image.YCbCr.SubsampleRatio must be 420")
	ErrYUVSubsampleRateMustI444 = errors.New("image.YCbCr.SubsampleRatio must be 444")
)
View Source
var (
	ErrMatchTemplateSAD          = errors.New("match_template_sad cgo call error")
	ErrMatchTemplateSSD          = errors.New("match_template_ssd cgo call error")
	ErrMatchTemplateNCC          = errors.New("match_template_ncc cgo call error")
	ErrMatchTemplateZNCC         = errors.New("match_template_zncc cgo call error")
	ErrCreatePrepareNCCTemplate  = errors.New("create_prepare_ncc_template cgo call error")
	ErrPrepareNCCTemplate        = errors.New("prepare_ncc_template cgo call error")
	ErrPreparedMatchTemplateNCC  = errors.New("prepated_match_template_ncc cgo call error")
	ErrCreatePrepareZNCCTemplate = errors.New("create_prepare_zncc_template cgo call error")
	ErrPrepareZNCCTemplate       = errors.New("prepare_zncc_template cgo call error")
	ErrPreparedMatchTemplateZNCC = errors.New("prepated_match_template_zncc cgo call error")
)
View Source
var (
	ErrBlend = errors.New("blend cgo call error")
)
View Source
var (
	ErrBlockmozaic = errors.New("contrast cgo call error")
)
View Source
var (
	ErrBoxblur = errors.New("boxblur cgo call error")
)
View Source
var (
	ErrBrightness = errors.New("brightness cgo call error")
)
View Source
var (
	ErrCanny = errors.New("canny cgo call error")
)
View Source
var (
	ErrClone = errors.New("clone cgo call error")
)
View Source
var (
	ErrContour = errors.New("contour cgo call error")
)
View Source
var (
	ErrContrast = errors.New("contrast cgo call error")
)
View Source
var (
	ErrConvertFromRGBA = errors.New("convert_from cgo call error")
)
View Source
var (
	ErrCrop = errors.New("crop cgo call error")
)
View Source
var (
	ErrDilation = errors.New("dilation cgo call error")
)
View Source
var (
	ErrEdge = errors.New("edge cgo call error")
)
View Source
var (
	ErrEmboss = errors.New("emboss cgo call error")
)
View Source
var (
	ErrErosion = errors.New("erosion cgo call error")
)
View Source
var (
	ErrFlip = errors.New("flip cgo call error")
)
View Source
var (
	ErrGamma = errors.New("gamma cgo call error")
)
View Source
var (
	ErrGaussianblur = errors.New("gaussianblur cgo call error")
)
View Source
var (
	ErrGradient = errors.New("gradient cgo call error")
)
View Source
var (
	ErrGrayscale = errors.New("grayscale cgo call error")
)
View Source
var (
	ErrHighpass = errors.New("highpass cgo call error")
)
View Source
var (
	ErrInvert = errors.New("invert cgo call error")
)
View Source
var (
	ErrLaplacian = errors.New("laplacian cgo call error")
)
View Source
var (
	ErrMorphology = errors.New("morphology cgo call error")
)
View Source
var (
	ErrPCM16Decibel = errors.New("pcm16_decibel cgo call error")
)
View Source
var (
	ErrRotate = errors.New("rotate cgo call error")
)
View Source
var (
	ErrScale = errors.New("scale cgo call error")
)
View Source
var (
	ErrSobel = errors.New("sobel cgo call error")
)

Functions

func Blend added in v1.16.0

func Blend(src0 *image.RGBA, src1 *image.RGBA, pt image.Point, mode BlendMode) (*image.RGBA, error)

func Blockmozaic added in v1.1.0

func Blockmozaic(img *image.RGBA, block int) (*image.RGBA, error)

func Boxblur

func Boxblur(img *image.RGBA, size uint8) (*image.RGBA, error)

func Brightness

func Brightness(img *image.RGBA, factor float64) (*image.RGBA, error)

func Canny added in v1.8.0

func Canny(img *image.RGBA, thresholdMax, thresholdMin int) (*image.RGBA, error)

func CannyWithDilate added in v1.9.0

func CannyWithDilate(img *image.RGBA, thresholdMax, thresholdMin int, dilateSize int) (*image.RGBA, error)

func Clone

func Clone(img *image.RGBA) (*image.RGBA, error)

func Contour added in v1.19.0

func Contour(img *image.RGBA, threshold uint8, size uint8) ([]image.Point, error)

func Contrast

func Contrast(img *image.RGBA, factor float64) (*image.RGBA, error)

func ConvertFrom added in v1.17.0

func ConvertFrom(img *image.RGBA, model ColorModel) (*image.RGBA, error)

func ConvertFromABGR added in v1.17.0

func ConvertFromABGR(img *image.RGBA) (*image.RGBA, error)

func ConvertFromARGB added in v1.17.0

func ConvertFromARGB(img *image.RGBA) (*image.RGBA, error)

func ConvertFromBGRA added in v1.17.0

func ConvertFromBGRA(img *image.RGBA) (*image.RGBA, error)

func ConvertFromRABG added in v1.17.0

func ConvertFromRABG(img *image.RGBA) (*image.RGBA, error)

func ConvertFromYUV added in v1.17.0

func ConvertFromYUV(img *image.YCbCr, chrs ChromaSubsampling) (*image.RGBA, error)

func ConvertFromYUV420 added in v1.17.0

func ConvertFromYUV420(img *image.YCbCr) (*image.RGBA, error)

func ConvertFromYUV420Plane added in v1.17.0

func ConvertFromYUV420Plane(y, u, v []byte, y_stride, u_stride, v_stride int, width, height int) (*image.RGBA, error)

func ConvertFromYUV444 added in v1.17.0

func ConvertFromYUV444(img *image.YCbCr) (*image.RGBA, error)

func ConvertFromYUV444Plane added in v1.17.0

func ConvertFromYUV444Plane(y, u, v []byte, y_stride, u_stride, v_stride int, width, height int) (*image.RGBA, error)

func ConvertToYUV420 added in v1.19.0

func ConvertToYUV420(img *image.RGBA) (*image.YCbCr, error)

func ConvertToYUV444 added in v1.17.0

func ConvertToYUV444(img *image.RGBA) (*image.YCbCr, error)

func Crop added in v1.18.0

func Crop(img *image.RGBA, pt image.Point, cropWidth, cropHeight int) (*image.RGBA, error)

func Dilation added in v1.7.0

func Dilation(img *image.RGBA, size int) (*image.RGBA, error)

func DisablePool

func DisablePool()

func Edge added in v1.2.0

func Edge(img *image.RGBA) (*image.RGBA, error)

func Emboss added in v1.4.0

func Emboss(img *image.RGBA) (*image.RGBA, error)

func EnablePool

func EnablePool()

func Erosion added in v1.7.0

func Erosion(img *image.RGBA, size int) (*image.RGBA, error)

func Flip added in v1.19.0

func Flip(img *image.RGBA, mode FlipMode) (*image.RGBA, error)

func FreePreparedNCCTemplate added in v1.14.0

func FreePreparedNCCTemplate(ptpl *PreparedNCCTpl)

func FreePreparedZNCCTemplate added in v1.15.0

func FreePreparedZNCCTemplate(ptpl *PreparedZNCCTpl)

func Gamma

func Gamma(img *image.RGBA, factor float64) (*image.RGBA, error)

func Gaussianblur

func Gaussianblur(img *image.RGBA, sigma float64) (*image.RGBA, error)

func GetByteBuf added in v1.2.0

func GetByteBuf(size int) []byte

func GetRGBA added in v1.2.0

func GetRGBA(width, height int) *image.RGBA

func GetRGBAByteBuf added in v1.12.0

func GetRGBAByteBuf(width, height int) []byte

func Gradient added in v1.7.0

func Gradient(img *image.RGBA) (*image.RGBA, error)

func Grayscale

func Grayscale(img *image.RGBA) (*image.RGBA, error)

func Highpass added in v1.7.0

func Highpass(img *image.RGBA) (*image.RGBA, error)

func Invert added in v1.3.0

func Invert(img *image.RGBA) (*image.RGBA, error)

func Laplacian added in v1.6.0

func Laplacian(img *image.RGBA) (*image.RGBA, error)

func Morphology added in v1.10.0

func Morphology(img *image.RGBA, mode MorphologyMode, size int, count int) (*image.RGBA, error)

func MorphologyCanny added in v1.10.0

func MorphologyCanny(img *image.RGBA, thresholdMax, thresholdMin int, mode CannyMorphologyMode, morphSize int) (*image.RGBA, error)

func MorphologyCannyWithDilate added in v1.10.0

func MorphologyCannyWithDilate(
	img *image.RGBA,
	thresholdMax, thresholdMin int,
	mode CannyMorphologyMode,
	morphSize int,
	dilateSize int,
) (*image.RGBA, error)

func NativePCM16Decibel added in v1.20.0

func NativePCM16Decibel(data []int16) float64

func PCM16Decibel added in v1.20.0

func PCM16Decibel(data []byte, length int) (float32, error)

func PCM16DecibelFromInt16 added in v1.20.0

func PCM16DecibelFromInt16(data []int16) (float32, error)

func PutByteBuf added in v1.2.0

func PutByteBuf(data []byte)

func PutRGBA added in v1.2.0

func PutRGBA(img *image.RGBA)

func PutRGBAByteBuf added in v1.12.0

func PutRGBAByteBuf(data []byte)

func Rotate added in v1.5.0

func Rotate(img *image.RGBA, mode RotationMode) (*image.RGBA, error)

func Scale added in v1.18.0

func Scale(img *image.RGBA, scaleWidth, scaleHeight int, mode ScaleFilter) (*image.RGBA, error)

func Sobel

func Sobel(img *image.RGBA) (*image.RGBA, error)

Types

type BlendMode added in v1.16.0

type BlendMode uint8
const (
	BlendNormal BlendMode = iota
	BlendSub
	BlendAdd
	BlendDiff
)

type CannyMorphologyMode added in v1.10.0

type CannyMorphologyMode uint8
const (
	CannyMorphologyNone CannyMorphologyMode = iota
	CannyMorphologyOpen
	CannyMorphologyClose
)

type ChromaSubsampling added in v1.17.0

type ChromaSubsampling uint8
const (
	ChromaSubsampling420 ChromaSubsampling = iota + 1
	ChromaSubsampling444
)

type ColorModel added in v1.17.0

type ColorModel uint8
const (
	ColorModelARGB ColorModel = iota + 1
	ColorModelABGR
	ColorModelBGRA
	ColorModelRABG
)

type FlipMode added in v1.19.0

type FlipMode uint8
const (
	FlipVertical FlipMode = iota + 1
	FlipHorizon
)

type MatchTemplateFloatScore added in v1.13.0

type MatchTemplateFloatScore struct {
	Point image.Point
	Score float64
}

func MatchTemplateNCC added in v1.13.0

func MatchTemplateNCC(img *image.RGBA, tpl *image.RGBA, threshold float64) ([]MatchTemplateFloatScore, error)

func MatchTemplateZNCC added in v1.14.0

func MatchTemplateZNCC(img *image.RGBA, tpl *image.RGBA, threshold float64) ([]MatchTemplateFloatScore, error)

func PreparedMatchTemplateNCC added in v1.14.0

func PreparedMatchTemplateNCC(img *image.RGBA, ptpl *PreparedNCCTpl, threshold float64) ([]MatchTemplateFloatScore, error)

func PreparedMatchTemplateZNCC added in v1.15.0

func PreparedMatchTemplateZNCC(img *image.RGBA, ptpl *PreparedZNCCTpl, threshold float64) ([]MatchTemplateFloatScore, error)

type MatchTemplateIntScore added in v1.13.0

type MatchTemplateIntScore struct {
	Point image.Point
	Score uint32
}

func MatchTemplateSAD added in v1.12.0

func MatchTemplateSAD(img *image.RGBA, tpl *image.RGBA, threshold uint16) ([]MatchTemplateIntScore, error)

func MatchTemplateSSD added in v1.12.0

func MatchTemplateSSD(img *image.RGBA, tpl *image.RGBA, threshold uint32) ([]MatchTemplateIntScore, error)

type MorphologyMode added in v1.10.0

type MorphologyMode uint8
const (
	MorphologyOpen MorphologyMode = iota + 1
	MorphologyClose
	MorphologyGradient
)

type PreparedNCCTpl added in v1.14.0

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

func PrepareNCCTemplate added in v1.14.0

func PrepareNCCTemplate(tpl *image.RGBA) (*PreparedNCCTpl, error)

type PreparedZNCCTpl added in v1.15.0

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

func PrepareZNCCTemplate added in v1.15.0

func PrepareZNCCTemplate(tpl *image.RGBA) (*PreparedZNCCTpl, error)

type RotationMode added in v1.5.0

type RotationMode int16
const (
	Rotate0   RotationMode = 0   // No rotation
	Rotate90  RotationMode = 90  // Rotate 90 degrees clockwise
	Rotate180 RotationMode = 180 // Rotate 180 degrees
	Rotate270 RotationMode = 270 // Rotate 270 degrees clockwise
)

type ScaleFilter added in v1.18.0

type ScaleFilter uint8
const (
	ScaleFilterNone ScaleFilter = iota
	ScaleFilterBox
	ScaleFilterLinear
	ScaleFilterGaussian
)

Directories

Path Synopsis
benchmark module
cli
cgo
cmd
cgo

Jump to

Keyboard shortcuts

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