filterx

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package filterx 模糊

Package filterx 模糊

Package filterx 二值化

Package filterx 膨胀

Package filterx 边缘化

Package filterx 浮雕

Package filterx 腐蚀

Package filterx RGBA转RGB

Package filterx 锐化

Index

Constants

This section is empty.

Variables

View Source
var (
	// BoxFourNear3
	// 3x3 4邻域均值滤波器
	BoxFourNear3 = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 4,
		Kernel: []KernelVector{
			{0, -1, 1}, {-1, 0, 1},
			{1, +0, 1}, {+0, 1, 1}, {0, 0, 1}}}
	// BoxEightNear3
	// 3x3 8邻域均值滤波器
	BoxEightNear3 = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 8,
		Kernel: []KernelVector{
			{-1, -1, 1}, {0, -1, 1}, {1, -1, 1},
			{-1, +0, 1}, {1, +0, 1},
			{-1, +1, 1}, {0, +1, 1}, {1, +1, 1}}}
	// BoxAverage3
	// 3x3 均值滤波器
	BoxAverage3 = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 9,
		Kernel: []KernelVector{
			{-1, -1, 1}, {0, -1, 1}, {1, -1, 1},
			{-1, +0, 1}, {0, +0, 1}, {1, +0, 1},
			{-1, +1, 1}, {0, +1, 1}, {1, +1, 1}}}
)

均值模糊滤波器

View Source
var (
	// Gauss3
	// 3x3 高斯滤波器
	Gauss3 = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 16,
		Kernel: []KernelVector{
			{-1, -1, 1}, {0, -1, 2}, {1, -1, 1},
			{-1, +0, 2}, {0, +0, 4}, {1, +0, 2},
			{-1, +1, 1}, {0, +1, 2}, {1, +1, 1}}}
	// Gauss5
	// 5x5 高斯滤波器
	Gauss5 = FilterMatrix{KernelRadius: 2, KernelSize: 5, KernelScale: 273,
		Kernel: []KernelVector{
			{-2, -2, 1}, {-1, -2, 4}, {0, -2, 7}, {1, -2, 4}, {2, -2, 1},
			{-2, -1, 4}, {-1, -1, 16}, {0, -1, 26}, {1, -1, 16}, {2, -1, 4},
			{-2, +0, 7}, {-1, +0, 26}, {0, +0, 41}, {1, +0, 26}, {2, +0, 7},
			{-2, +1, 4}, {-1, +1, 16}, {0, +1, 26}, {1, +1, 16}, {2, +1, 4},
			{-2, +2, 1}, {-1, +2, 4}, {1, +2, 7}, {1, +2, 4}, {2, +2, 1}}}
)

高斯模糊滤波器

View Source
var (
	// Motion3Horizontal
	// 3x3水平运动滤波器
	Motion3Horizontal = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 3,
		Kernel: []KernelVector{
			{-1, 0, 1}, {0, 0, 1}, {1, 0, 1}}}
	// Motion3Vertical
	// 3x3垂直运动滤波器
	Motion3Vertical = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 3,
		Kernel: []KernelVector{
			{0, -1, 1}, {0, 0, 1}, {0, 1, 1}}}
	// Motion3Oblique45
	// 3x3 45度运动滤波器(左上右下)
	Motion3Oblique45 = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 3,
		Kernel: []KernelVector{
			{1, -1, 1}, {0, +0, 1}, {-1, +1, 1}}}
	// Motion3Oblique135
	// 3x3 135度运动滤波器(左下右上)
	Motion3Oblique135 = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 3,
		Kernel: []KernelVector{
			{-1, -1, 1}, {0, 0, 1}, {1, 1, 1}}}
)

运动模糊滤波器

View Source
var (
	// Edge5LR 5x5 左右边缘滤波器
	Edge5LR = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 0,
		Kernel: []KernelVector{
			{-2, 0, -1}, {-1, 0, -1}, {0, 0, 4}, {1, 0, -1}, {2, 0, -1}}}
	// Edge5UD 5x5 上下边缘滤波器
	Edge5UD = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 0,
		Kernel: []KernelVector{
			{0, -2, -1}, {0, -1, -1}, {0, 0, 4}, {0, 1, -1}, {0, 2, -1}}}
	// Edge5LuRd 5x5 左上右下边缘滤波器
	Edge5LuRd = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 0,
		Kernel: []KernelVector{
			{-2, -2, -1}, {-1, -1, -1}, {0, 0, 4}, {1, 1, -1}, {1, 2, -1}}}
	// Edge5LdRu 5x5 左下右上边缘滤波器
	Edge5LdRu = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 0,
		Kernel: []KernelVector{
			{-2, 2, -1}, {-1, 1, -1}, {0, 0, 4}, {1, -1, -1}, {2, -2, -1}}}

	// Edge3Laplace4 3x3 Laplace拉普拉斯4邻滤波器
	Edge3Laplace4 = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 0,
		Kernel: []KernelVector{
			{0, -1, -1}, {-1, +0, -1}, {0, +0, +4}, {1, +0, -1}, {0, +1, -1}}}
	// Edge3Laplace8 5x5 Laplace拉普拉斯8邻滤波器
	Edge3Laplace8 = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 0,
		Kernel: []KernelVector{
			{-1, -1, -1}, {0, -1, -1}, {1, -1, -1},
			{-1, +0, -1}, {0, +0, +8}, {1, +0, -1},
			{-1, +1, -1}, {0, +1, -1}, {1, +1, -1}}}
)

边缘滤波器

View Source
var (
	// Emboss3Lu2Rd 3x3 (左上->右下)浮雕滤波器
	Emboss3Lu2Rd = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 0, ResultOffset: 32768,
		Kernel: []KernelVector{
			{-1, -1, -1}, {-0, -1, -1},
			{-1, -0, -1}, {+1, +0, +1},
			{+0, +1, +1}, {+1, +1, +1}}}
	// Emboss3U2D 3x3 (上->下)浮雕滤波器
	Emboss3U2D = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 0, ResultOffset: 32768,
		Kernel: []KernelVector{
			{-1, -1, -1}, {0, -1, -1}, {+1, -1, -1},
			{-1, +1, +1}, {0, +1, +1}, {+1, +1, +1}}}
	// Emboss5Lu2Rd 5x5 (左上->右下)浮雕滤波器
	Emboss5Lu2Rd = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 0, ResultOffset: 32768,
		Kernel: []KernelVector{
			{-2, -2, -1}, {-1, -2, -1}, {+0, -2, -1}, {+1, -2, -1},
			{-2, -1, -1}, {-1, -1, -1}, {+0, -1, -1}, {+2, -1, +1},
			{-2, -0, -1}, {-1, -0, -1}, {+1, -0, +1}, {+2, -0, +1},
			{-2, +1, -1}, {+0, +1, +1}, {+1, +1, +1}, {+2, +1, +1},
			{-1, +2, +1}, {+0, +2, +1}, {+1, +2, +1}, {+2, +2, +1}}}
	// Emboss5U2D 5x5 (上->下)浮雕滤波器
	Emboss5U2D = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 0, ResultOffset: 32768,
		Kernel: []KernelVector{
			{-2, -2, -1}, {-1, -2, -1}, {0, -2, -1}, {+1, -2, -1}, {+2, -2, -1},
			{-2, -1, -1}, {-1, -1, -1}, {0, -1, -1}, {+1, -0, -1}, {+2, -1, -1},
			{-2, +1, +1}, {-1, +1, +1}, {0, +1, +1}, {+1, +1, +1}, {+2, +1, +1},
			{-2, +2, +1}, {-1, +2, +1}, {0, +2, +1}, {+1, +2, +1}, {+2, +2, +1}}}
	// Emboss3Asymmetrical 3x3 非对称浮雕滤波器
	Emboss3Asymmetrical = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 0, ResultOffset: 32768,
		Kernel: []KernelVector{
			{-1, -1, 2}, {+0, +0, -1}, {+1, +1, -1}}}
)

浮雕滤波器

View Source
var (
	// Sharpen3Laplace4
	// 3x3 简单锐化滤波器(拉普拉斯4邻滤波器)
	Sharpen3Laplace4 = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 1,
		Kernel: []KernelVector{
			{0, -1, -1}, {-1, +0, -1}, {0, +0, +5}, {1, +0, -1}, {0, +1, -1}}}
	// Sharpen3Laplace8
	// 3x3 锐化滤波器(拉普拉斯8邻滤波器)
	Sharpen3Laplace8 = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 1,
		Kernel: []KernelVector{
			{-1, -1, -1}, {0, -1, -1}, {1, -1, -1},
			{-1, +0, -1}, {0, +0, +9}, {1, +0, -1},
			{-1, +1, -1}, {0, +1, -1}, {1, +1, -1}}}
	// SharpenStrengthen3All
	// 3x3 全方向锐化滤波器(强调边缘)
	SharpenStrengthen3All = FilterMatrix{KernelRadius: 1, KernelSize: 3, KernelScale: 1,
		Kernel: []KernelVector{
			{-1, -1, +1}, {0, -1, +1}, {1, -1, +1},
			{-1, +0, +1}, {0, +0, -7}, {1, +0, +1},
			{-1, +1, +1}, {0, +1, +1}, {1, +1, +1}}}
	// Sharpen5All
	// 5x5 全方向锐化滤波器
	Sharpen5All = FilterMatrix{KernelRadius: 2, KernelSize: 5, KernelScale: 1,
		Kernel: []KernelVector{
			{-2, -2, -1}, {-1, -2, -1}, {0, -2, -1}, {1, -2, -1}, {2, -2, -1},
			{-2, -1, -1}, {-1, -1, +2}, {0, -1, +2}, {1, -1, +2}, {2, -1, -1},
			{-2, +0, -1}, {-1, +0, +2}, {0, +0, +1}, {1, +0, +2}, {2, +0, -1},
			{-2, +1, -1}, {-1, +1, +2}, {0, +1, +2}, {1, +1, +2}, {2, +1, -1},
			{-2, +2, -1}, {-1, +2, -1}, {1, +2, -1}, {1, +2, -1}, {2, +2, -1}}}
)

锐化滤波器

Functions

func BlurWithAverage3

func BlurWithAverage3(srcImg image.Image, dstImg draw.Image) error

BlurWithAverage3 均值模糊

func BlurWithBoxEight

func BlurWithBoxEight(srcImg image.Image, dstImg draw.Image, radius int, includeCenter bool) error

BlurWithBoxEight 自定义8邻均值模糊

func BlurWithBoxFour

func BlurWithBoxFour(srcImg image.Image, dstImg draw.Image, radius int, includeCenter bool) error

BlurWithBoxFour 自定义4邻均值模糊

func BlurWithEightNear3

func BlurWithEightNear3(srcImg image.Image, dstImg draw.Image) error

BlurWithEightNear3 8邻域均值模糊

func BlurWithForeNear3

func BlurWithForeNear3(srcImg image.Image, dstImg draw.Image) error

BlurWithForeNear3 4邻域均值模糊

func BlurWithGauss

func BlurWithGauss(srcImg image.Image, dstImg draw.Image, radius int, sigma float64) error

BlurWithGauss 自定义高斯模糊

func BlurWithGauss3

func BlurWithGauss3(srcImg image.Image, dstImg draw.Image) error

BlurWithGauss3 高斯3x3模糊

func BlurWithGauss5

func BlurWithGauss5(srcImg image.Image, dstImg draw.Image) error

BlurWithGauss5 高斯5x5模糊

func BlurWithMotion

func BlurWithMotion(srcImg image.Image, dstImg draw.Image, radius int, direction imagex.PixelDirection) error

BlurWithMotion 自定义运动模糊

func BlurWithMotion3Horizontal

func BlurWithMotion3Horizontal(srcImg image.Image, dstImg draw.Image) error

BlurWithMotion3Horizontal 水平运动模糊

func BlurWithMotion3Oblique135

func BlurWithMotion3Oblique135(srcImg image.Image, dstImg draw.Image) error

BlurWithMotion3Oblique135 斜135角运动模糊

func BlurWithMotion3Oblique45

func BlurWithMotion3Oblique45(srcImg image.Image, dstImg draw.Image) error

BlurWithMotion3Oblique45 斜45角运动模糊

func BlurWithMotion3Vertical

func BlurWithMotion3Vertical(srcImg image.Image, dstImg draw.Image) error

BlurWithMotion3Vertical 垂直运动模糊

func CVTGray

func CVTGray(graySrcImg image.Image, grayDstImg draw.Image, threshold uint32) error

CVTGray 二值化灰度图 threshold [0, 65535]

func CVTGrayImageWithKittle

func CVTGrayImageWithKittle(srcImg image.Image, dstImg draw.Image) error

CVTGrayImageWithKittle Kittle二值化算法(灰度拉伸)

func CVTWithOTSU

func CVTWithOTSU(srcImg image.Image, dstImg draw.Image) error

CVTWithOTSU OTSU二值化算法(大津法)

func CVTWithOTSU64

func CVTWithOTSU64(srcImg image.Image, dstImg draw.Image) error

CVTWithOTSU64 OTSU二值化算法(大津法)

func DilateCVT

func DilateCVT(cvtSrcImg image.Image, cvtDstImg draw.Image, directions imagex.PixelDirection) error

DilateCVT 膨胀二值图 只要不是纯白,都会发生膨胀 directions为允许膨胀的方向

func DilateGray

func DilateGray(graySrcImg image.Image, grayDstImg draw.Image, directions imagex.PixelDirection, threshold uint32) error

DilateGray 膨胀灰度图像(用于普通灰度图意义不太,二值图的效果不错) 阈值threshold, 只有<=threshold的像素点才会向外发生膨胀 阈值threshold范围[0,65535] directions为允许膨胀的方向

func EdgeCustom

func EdgeCustom(srcImg image.Image, dstImg draw.Image, radius int, direction imagex.PixelDirection, diff uint) error

EdgeCustom 使用自定义边缘滤波器处理图像

func EdgeWithCustomLaplace4

func EdgeWithCustomLaplace4(srcImg image.Image, dstImg draw.Image, radius int) error

EdgeWithCustomLaplace4 使用自定义拉普拉斯4邻边缘滤波器处理图像

func EdgeWithCustomLaplace8

func EdgeWithCustomLaplace8(srcImg image.Image, dstImg draw.Image, radius int) error

EdgeWithCustomLaplace8 使用自定义拉普拉斯8邻边缘滤波器处理图像

func EdgeWithLR

func EdgeWithLR(srcImg image.Image, dstImg draw.Image) error

EdgeWithLR 使用左右边缘滤波器处理图像

func EdgeWithLaplace4

func EdgeWithLaplace4(srcImg image.Image, dstImg draw.Image) error

EdgeWithLaplace4 使用全方向边缘滤波器处理图像

func EdgeWithLaplace8

func EdgeWithLaplace8(srcImg image.Image, dstImg draw.Image) error

EdgeWithLaplace8 使用全方向边缘滤波器处理图像

func EdgeWithLdRu

func EdgeWithLdRu(srcImg image.Image, dstImg draw.Image) error

EdgeWithLdRu 使用左下右上边缘滤波器处理图像

func EdgeWithLuRd

func EdgeWithLuRd(srcImg image.Image, dstImg draw.Image) error

EdgeWithLuRd 使用左上右下边缘滤波器处理图像

func EdgeWithUD

func EdgeWithUD(srcImg image.Image, dstImg draw.Image) error

EdgeWithUD 使用上下边缘滤波器处理图像

func ErodeCVT

func ErodeCVT(cvtSrcImg image.Image, cvtDstImg draw.Image, directions imagex.PixelDirection) error

ErodeCVT 腐蚀二值图

func ErodeGray

func ErodeGray(graySrcImg image.Image, grayDstImg draw.Image, directions imagex.PixelDirection, erodeThreshold uint32, antiErodeThreshold uint32) error

ErodeGray 腐蚀灰度图像 腐蚀阈值erodeThreshold (0,65535]

>=erodeThreshold像素的点才具有腐蚀性
erodeThreshold=1时只要不是纯黑都具有腐蚀性,erodeThreshold=65535时只有纯白具有腐蚀性

抗腐蚀阈值antiErodeThreshold [0, 65535)

<antiErodeThreshold的像素点不会被腐蚀,
antiErodeThreshold=0时不抗腐蚀

要求 erodeThreshold > antiErodeThreshold

func FastBlur added in v1.0.3

func FastBlur(srcImg image.Image, dstImg draw.Image, radius int) error

func FastBlur2 added in v1.0.3

func FastBlur2(srcImg image.Image, dstImg draw.Image, radius int) error

func FastBlur3 added in v1.0.3

func FastBlur3(srcImg image.Image, dstImg draw.Image, radius int) error

func FastBlur64 added in v1.0.3

func FastBlur64(srcImg image.Image, dstImg draw.Image, radius int) error

FastBlur64 模糊

func FastBlurARGB8888 added in v1.0.3

func FastBlurARGB8888(srcImg image.Image, dstImg draw.Image, radius int) error

FastBlurARGB8888 堆模糊(快速模糊) https://www.cnblogs.com/Darksun/p/4681476.html FastBlurDemo.zip

func FastBlur_Java added in v1.0.3

func FastBlur_Java(srcImg image.Image, dstImg draw.Image, radius int) error

FastBlur_Java FastBlur.java

func FilterImageWithMatrix

func FilterImageWithMatrix(srcImg image.Image, dstImg draw.Image, m FilterMatrix) error

FilterImageWithMatrix 使用滤波器

func GetGray16Pixel

func GetGray16Pixel(grayImg *image.Gray16) (pixel [][]uint16)

func GetGrayPixel

func GetGrayPixel(grayImg *image.Gray) (pixel [][]uint8)

func GetKittleThresholdAtGreen

func GetKittleThresholdAtGreen(grayImg image.Image) (threshold uint32)

GetKittleThresholdAtGreen 计算Kittler算法的阈值 64位图像阈值 threshold [0, 65535]

func GetOtsuThreshold

func GetOtsuThreshold(grayImg image.Image) (threshold uint32)

GetOtsuThreshold 计算灰度图的OTSU算法的阈值 64位像素强制转为32位像素参与计算 结果返回64位图像级阈值 threshold [0, 65535]

func GetOtsuThreshold64

func GetOtsuThreshold64(grayImg image.Image) (threshold uint32)

GetOtsuThreshold64 计算灰度图的OTSU算法的阈值 结果返回64位图像级阈值 threshold [0, 65535]

func GrayDefaultFromNRGBA

func GrayDefaultFromNRGBA(src image.Image) (resultImage image.Image, err error)

GrayDefaultFromNRGBA 转制NRGBA图像为Gray16灰度图 使用默认灰度计算算法

func GrayDefaultFromRGBA

func GrayDefaultFromRGBA(src image.Image, backgroundColor color.Color) (resultImage image.Image, err error)

GrayDefaultFromRGBA 转制RGBA图像为Gray16灰度图 使用默认灰度计算算法

func GrayFromNRGBA

func GrayFromNRGBA(rgbImg image.Image, algMode graphicx.GrayAlgMode) (resultImage image.Image, err error)

GrayFromNRGBA 转制NRGBA图像为Gray16灰度图

func GrayFromRGBA

func GrayFromRGBA(rgbaImg image.Image, background color.Color, algMode graphicx.GrayAlgMode) (resultImage image.Image, err error)

GrayFromRGBA 转制RGBA图像为Gray16灰度图

func NRGBAAt added in v1.0.4

func NRGBAAt(rgbaImg image.Image, nrgbaImg draw.Image, backgroundColor color.Color) error

NRGBAAt 以某个背景色作底转换RGBA图像为NRGBA图像(去Alpha通道)

func NRGBAAtBlack added in v1.0.4

func NRGBAAtBlack(rgbaImg image.Image, nrgbaImg draw.Image) error

NRGBAAtBlack 以黑色(Black)作底转换RGBA图像为RGB图像(去Alpha通道)

func NRGBAAtGreen added in v1.0.4

func NRGBAAtGreen(rgbaImg image.Image, nrgbaImg draw.Image) error

NRGBAAtGreen 以绿色(Green)作底转换RGBA图像为RGB图像(去Alpha通道)

func NRGBAAtWhite added in v1.0.4

func NRGBAAtWhite(rgbaImg image.Image, nrgbaImg draw.Image) error

NRGBAAtWhite 以白色(White)作底转换RGBA图像为RGB图像(去Alpha通道)

func SharpenWithCustomLaplace

func SharpenWithCustomLaplace(srcImg image.Image, dstImg draw.Image, radius int, direction imagex.PixelDirection) error

SharpenWithCustomLaplace 使用定制的拉普拉斯锐化滤波器处理图像

func SharpenWithLaplace4

func SharpenWithLaplace4(srcImg image.Image, dstImg draw.Image) error

SharpenWithLaplace4 使用拉普拉斯4邻锐化滤波器处理图像

func SharpenWithLaplace8

func SharpenWithLaplace8(srcImg image.Image, dstImg draw.Image) error

SharpenWithLaplace8 使用拉普拉斯4邻锐化滤波器处理图像

func SharpenWithSharpen5All

func SharpenWithSharpen5All(srcImg image.Image, dstImg draw.Image) error

SharpenWithSharpen5All 使用强调边缘滤波器处理图像

func SharpenWithStrengthen3

func SharpenWithStrengthen3(srcImg image.Image, dstImg draw.Image) error

SharpenWithStrengthen3 使用强调边缘滤波器处理图像

Types

type EmbossDirection

type EmbossDirection int
const (
	Lu2Rd EmbossDirection = iota
	Ru2Ld
	Rd2Lu
	Ld2Ru

	U2D
	R2L
	D2U
	L2R
)

以下顺序不能乱

type FilterKernel

type FilterKernel []KernelVector

func (FilterKernel) Clone

func (fk FilterKernel) Clone() FilterKernel

func (FilterKernel) FlipLR

func (fk FilterKernel) FlipLR() FilterKernel

FlipLR 左右翻转

func (FilterKernel) FlipLRSelf

func (fk FilterKernel) FlipLRSelf()

FlipLRSelf 左右翻转自身

func (FilterKernel) FlipUD

func (fk FilterKernel) FlipUD() FilterKernel

FlipUD 上下翻转

func (FilterKernel) FlipUDSelf

func (fk FilterKernel) FlipUDSelf()

FlipUDSelf 上下翻转自身

func (FilterKernel) Len

func (fk FilterKernel) Len() int

func (FilterKernel) Less

func (fk FilterKernel) Less(i, j int) bool

func (FilterKernel) Rotate

func (fk FilterKernel) Rotate(clockwise bool, count90 int) FilterKernel

Rotate 旋转

func (FilterKernel) Rotate90

func (fk FilterKernel) Rotate90(clockwise bool) FilterKernel

Rotate90 旋转90度 clockwise ;是否为顺时针

func (FilterKernel) Rotate90Self

func (fk FilterKernel) Rotate90Self(clockwise bool)

Rotate90Self 旋转90度 clockwise ;是否为顺时针

func (FilterKernel) RotateSelf

func (fk FilterKernel) RotateSelf(clockwise bool, count90 int)

RotateSelf 旋转

func (FilterKernel) Sorted

func (fk FilterKernel) Sorted()

Sorted 核排序

func (FilterKernel) Swap

func (fk FilterKernel) Swap(i, j int)

type FilterMatrix

type FilterMatrix struct {
	// 滤波器卷积核
	Kernel FilterKernel
	// 滤波器半径
	KernelRadius int
	// 滤波器边长
	KernelSize int
	// 滤波器卷积核倍率
	KernelScale int
	// 运算结果偏移量
	ResultOffset int
}

FilterMatrix 滤波器

func CreateAsymmetricalEmbossFilter

func CreateAsymmetricalEmbossFilter(radius int, value int, offset int, angle int) (filter FilterMatrix, err error)

CreateAsymmetricalEmbossFilter 创建对称浮雕滤波器

func CreateBoxEightNearBlurFilter

func CreateBoxEightNearBlurFilter(radius int, includeCenter bool) (filter FilterMatrix, err error)

CreateBoxEightNearBlurFilter 创建自定义8邻均值模糊滤波器 radius 半径 includeCenter 包含中心

func CreateBoxFourNearBlurFilter

func CreateBoxFourNearBlurFilter(radius int, includeCenter bool) (filter FilterMatrix, err error)

CreateBoxFourNearBlurFilter 创建自定义4邻均值模糊滤波器 radius 半径 includeCenter 包含中心

func CreateEdgeFilter

func CreateEdgeFilter(radius int, direction imagex.PixelDirection, diff uint) (filter FilterMatrix, err error)

CreateEdgeFilter 创建边缘检测滤波器 radius: 卷积核半径 direction: 运动方向 diff: 梯度差

func CreateEdgeLaplace4Filter

func CreateEdgeLaplace4Filter(radius int) (filter FilterMatrix, err error)

CreateEdgeLaplace4Filter 创建拉普拉斯4邻边缘检测滤波器

func CreateEdgeLaplace8Filter

func CreateEdgeLaplace8Filter(radius int) (filter FilterMatrix, err error)

CreateEdgeLaplace8Filter 创建拉普拉斯8邻边缘检测滤波器

func CreateEmbossFilterSymmetry

func CreateEmbossFilterSymmetry(radius int, direction EmbossDirection, offset int) (filter FilterMatrix, err error)

CreateEmbossFilterSymmetry 创建对称浮雕滤波器

func CreateGaussBlurFilter

func CreateGaussBlurFilter(radius int, sigma float64) (filter FilterMatrix, err error)

CreateGaussBlurFilter 创建高斯模糊滤波器 radius: 卷积核半径 [1,3] sigma: 标准差

func CreateMotionBlurFilter

func CreateMotionBlurFilter(radius int, direction imagex.PixelDirection) (filter FilterMatrix, err error)

CreateMotionBlurFilter 创建运动模糊滤波器 radius: 卷积核半径 direction: 运动方向

func CreateSharpenFilter

func CreateSharpenFilter(radius int, direction imagex.PixelDirection, diff uint) (filter FilterMatrix, err error)

CreateSharpenFilter 创建边锐化滤波器 radius: 卷积核半径 direction: 运动方向 diff: 梯度差

func CreateSharpenLaplace4Filter

func CreateSharpenLaplace4Filter(radius int) (filter FilterMatrix, err error)

CreateSharpenLaplace4Filter 创建拉普拉斯4邻锐化滤波器

func CreateSharpenLaplace8Filter

func CreateSharpenLaplace8Filter(radius int) (filter FilterMatrix, err error)

CreateSharpenLaplace8Filter 创建拉普拉斯8邻锐化滤波器

func (FilterMatrix) CheckValidity

func (fm FilterMatrix) CheckValidity() error

CheckValidity 滤波模板有效性

func (FilterMatrix) FlipLR

func (fm FilterMatrix) FlipLR() FilterMatrix

FlipLR 左右翻转

func (FilterMatrix) FlipUD

func (fm FilterMatrix) FlipUD() FilterMatrix

FlipUD 上下翻转

func (FilterMatrix) IsPixelUnsafe

func (fm FilterMatrix) IsPixelUnsafe() bool

IsPixelUnsafe 运算结果是否可能超出像素范围(非安全像素值)

func (FilterMatrix) IsScaleMatrix

func (fm FilterMatrix) IsScaleMatrix() bool

IsScaleMatrix 是否为倍率滤波器

func (FilterMatrix) Rotate

func (fm FilterMatrix) Rotate(clockwise bool, count90 int) FilterMatrix

Rotate 顺时针旋转90度

type KernelVector

type KernelVector struct {
	//向量X
	X int
	//向量Y
	Y int
	//向量值
	Value int
}

KernelVector 滤波器向量单元

Jump to

Keyboard shortcuts

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