imop

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

It is mainly used to debug the seam carving operation correctness with face detection and image mask enabled. When the GUI mode and the debugging option is activated it will show the image mask and the detected faces rectangles in a distinct color.

Package imop implements the Porter-Duff composition operations used for mixing a graphic element with its backdrop. Porter and Duff presented in their paper 12 different composition operation, but the core image/draw core package implements only the source-over-destination and source. This package implements all of the 12 composite operation together with some blending modes.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bitmap

type Bitmap struct {
	Img *image.NRGBA
}

Bitmap holds an image type as a placeholder for the Porter-Duff composition operations which can be used as a source or destination image.

func NewBitmap

func NewBitmap(rect image.Rectangle) *Bitmap

NewBitmap initializes a new Bitmap.

type Blend

type Blend struct {
	CurrentOp BlendType
	Modes     []BlendType
}

Blend struct contains the currently active blend mode and all the supported blend modes.

func NewBlend

func NewBlend() *Blend

NewBlend intantiates a new Blend.

func (*Blend) AlphaCompose added in v1.4.6

func (bl *Blend) AlphaCompose(
	backdropAlpha,
	sourceAlpha,
	compositeAlpha,
	backdropColor,
	sourceColor,
	compositeColor float64,
) float64

Applies the alpha blending formula for a blend operation. See: https://www.w3.org/TR/compositing-1/#blending

func (*Blend) Get

func (bl *Blend) Get() BlendType

Get returns the active blend mode.

func (*Blend) Lum added in v1.4.6

func (bl *Blend) Lum(rgb Color) float64

Lum gets the luminosity of a color.

func (*Blend) Sat added in v1.4.6

func (bl *Blend) Sat(rgb Color) float64

Sat gets the saturation of a color.

func (*Blend) Set

func (bl *Blend) Set(blendType BlendType) error

Set activate one of the supported blend modes.

func (*Blend) SetLum added in v1.4.6

func (bl *Blend) SetLum(rgb Color, l float64) Color

SetLum set the luminosity on a color.

func (*Blend) SetSat added in v1.4.6

func (bl *Blend) SetSat(rgb Color, s float64) Color

type BlendType added in v1.5.0

type BlendType int
const (
	Normal BlendType = iota
	Darken
	Lighten
	Multiply
	Screen
	Overlay
	SoftLight
	HardLight
	ColorDodge
	ColorBurn
	Difference
	Exclusion

	// Non-separable blend modes
	Hue
	Saturation
	ColorMode
	Luminosity
)

type Color added in v1.4.6

type Color struct {
	R, G, B float64
}

Color represents the RGB channel of a specific color.

type CompType added in v1.5.0

type CompType int
const (
	Clear CompType = iota
	Copy
	Dst
	SrcOver
	DstOver
	SrcIn
	DstIn
	SrcOut
	DstOut
	SrcAtop
	DstAtop
	Xor
)

type Composite

type Composite struct {
	CurrentOp CompType
	Ops       []CompType
}

Composite struct contains the currently active composition operation and all the supported operations.

func InitOp

func InitOp() *Composite

InitOp initializes a new composition operation.

func (*Composite) Draw

func (op *Composite) Draw(bitmap *Bitmap, src, dst *image.NRGBA, blend *Blend)

Draw applies the currently active Ported-Duff composition operation formula, taking as parameter the source and the destination image and draws the result into the bitmap. If a blend mode is activated it will plug in the alpha blending formula also into the equation.

func (*Composite) Get added in v1.4.6

func (op *Composite) Get() CompType

Set changes the current composition operation.

func (*Composite) Set

func (op *Composite) Set(compType CompType) error

Set changes the current composition operation.

Jump to

Keyboard shortcuts

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