Skip to content

Latest commit

 

History

History
818 lines (482 loc) · 14.1 KB

File metadata and controls

818 lines (482 loc) · 14.1 KB

Blend

Blendmodes Index / Blendmodes / Blend

Auto-generated documentation for blendmodes.blend module.

_lum

Show source in blend.py:170

Luminosity.

Arguments

  • colours - x by x by 3 matrix of rgb color components of pixels

Returns

x by x by 3 matrix of luminosity of pixels

Signature

def _lum(colours: np.ndarray) -> np.ndarray: ...

_sat

Show source in blend.py:210

Saturation.

Arguments

  • colours - x by x by 3 matrix of rgb color components of pixels

Returns

int of saturation of pixels

Signature

def _sat(colours: np.ndarray) -> np.ndarray: ...

_setLum

Show source in blend.py:179

Set a new luminosity value for the matrix of color.

Signature

def _setLum(originalColours: np.ndarray, newLuminosity: np.ndarray) -> np.ndarray: ...

_setSat

Show source in blend.py:219

Set a new saturation value for the matrix of color.

Signature

def _setSat(originalColours: np.ndarray, newSaturation: np.ndarray) -> np.ndarray: ...

additive

Show source in blend.py:43

BlendType.ADDITIVE.

Signature

def additive(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

alpha_comp_shell

Show source in blend.py:623

Implement common transformations occurring in any blend or composite mode.

Signature

def alpha_comp_shell(
    lower_alpha: np.ndarray,
    upper_alpha: np.ndarray,
    lower_rgb: np.ndarray,
    upper_rgb: np.ndarray,
    blendType: BlendType,
) -> tuple[np.ndarray, np.ndarray]: ...

See also

blend

Show source in blend.py:402

Blend pixels.

Arguments


  • background np.ndarray - background
  • foreground np.ndarray - foreground
  • blendType BlendType - the blend type

Returns


  • np.ndarray - new array representing the image

  • background - np.ndarray,

  • foreground - np.ndarray and the return are in the form

[[[0. 0. 0.] [0. 0. 0.] [0. 0. 0.] ... [0. 0. 0.] [0. 0. 0.] [0. 0. 0.]]

...

[[0. 0. 0.] [0. 0. 0.] [0. 0. 0.] ... [0. 0. 0.] [0. 0. 0.] [0. 0. 0.]]]

Signature

def blend(
    background: np.ndarray, foreground: np.ndarray, blendType: BlendType
) -> np.ndarray: ...

See also

blendLayers

Show source in blend.py:469

Blend two layers (background and foreground), where the background may be cropped if smaller than the foreground.

:param Image.Image background: The background layer. :param Image.Image foreground: The foreground layer (must be the same size as the background).

Arguments

  • blendType BlendType - The blend type to be applied.
  • opacity float - The opacity of the foreground image. Defaults to 1.0. (optional) :param tuple[int, int] offsets: Offsets for the foreground layer. Defaults to (0, 0). (optional)

Returns

Type: Image.Image The combined image.

Examples

Blend two layers with default parameters

>>> combined_image = blendLayers(background_image, foreground_image, BlendType.NORMAL)

Blend two layers with custom opacity and offsets

>>> combined_image = blendLayers(
...	background_image,
...	foreground_image,
...	BlendType.MULTIPLY,
...	opacity=0.7,
...	offsets=(100, 50)
...)

Signature

def blendLayers(
    background: Image.Image,
    foreground: Image.Image,
    blendType: BlendType,
    opacity: float = 1.0,
    offsets: tuple[int, int] = (0, 0),
) -> Image.Image: ...

See also

blendLayersArray

Show source in blend.py:513

Blend two layers (background and foreground), where the background may be cropped if smaller than the foreground.

:param np.ndarray | Image.Image background: The background layer. :param np.ndarray | Image.Image foreground: The foreground layer (must be the same size as the background).

Arguments

  • blendType BlendType - The blend type to be applied.
  • opacity float - The opacity of the foreground image. Defaults to 1.0. (optional) :param tuple[int, int] offsets: Offsets for the foreground layer. Defaults to (0, 0). (optional)

Returns

Type: np.ndarray The combined image.

Examples

Blend two layers with default parameters

>>> combined_image = blendLayers(background_image, foreground_image, BlendType.NORMAL)

Blend two layers with custom opacity and offsets

>>> combined_image = blendLayers(
...	background_image,
...	foreground_image,
...	BlendType.MULTIPLY,
...	opacity=0.7,
...	offsets=(100, 50)
...)

Signature

def blendLayersArray(
    background: np.ndarray | Image.Image,
    foreground: np.ndarray | Image.Image,
    blendType: BlendType,
    opacity: float = 1.0,
    offsets: tuple[int, int] = (0, 0),
) -> np.ndarray: ...

See also

colour

Show source in blend.py:269

BlendType.COLOUR.

Signature

def colour(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

colourburn

Show source in blend.py:48

BlendType.COLOURBURN.

Signature

def colourburn(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

colourdodge

Show source in blend.py:56

BlendType.COLOURDODGE.

Signature

def colourdodge(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

darken

Show source in blend.py:102

BlendType.DARKEN.

Signature

def darken(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

destatop

Show source in blend.py:330

Place the layer below above the 'layer above' in places where the 'layer above' exists...

where 'layer below' does not exist, but 'layer above' does, place 'layer-above'

Signature

def destatop(
    backgroundAlpha: np.ndarray,
    foregroundAlpha: np.ndarray,
    backgroundColour: np.ndarray,
    foregroundColour: np.ndarray,
) -> tuple[np.ndarray, np.ndarray]: ...

destin

Show source in blend.py:279

'clip' composite mode.

All parts of 'layer above' which are alpha in 'layer below' will be made also alpha in 'layer above' (to whatever degree of alpha they were)

Destination which overlaps the source, replaces the source.

Fa = 0; Fb = as co = ab x Cb x as ao = ab x as

Signature

def destin(
    backgroundAlpha: np.ndarray,
    foregroundAlpha: np.ndarray,
    backgroundColour: np.ndarray,
    foregroundColour: np.ndarray,
) -> tuple[np.ndarray, np.ndarray]: ...

destout

Show source in blend.py:307

Reverse 'Clip' composite mode.

All parts of 'layer below' which are alpha in 'layer above' will be made also alpha in 'layer below' (to whatever degree of alpha they were)

Signature

def destout(
    backgroundAlpha: np.ndarray,
    foregroundAlpha: np.ndarray,
    backgroundColour: np.ndarray,
    foregroundColour: np.ndarray,
) -> tuple[np.ndarray, np.ndarray]: ...

difference

Show source in blend.py:87

BlendType.DIFFERENCE.

Signature

def difference(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

divide

Show source in blend.py:146

BlendType.DIVIDE.

Signature

def divide(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

exclusion

Show source in blend.py:165

BlendType.EXCLUSION.

Signature

def exclusion(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

glow

Show source in blend.py:70

BlendType.GLOW.

Signature

def glow(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

grainextract

Show source in blend.py:136

BlendType.GRAINEXTRACT.

Signature

def grainextract(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

grainmerge

Show source in blend.py:141

BlendType.GRAINMERGE.

Signature

def grainmerge(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

hardlight

Show source in blend.py:127

BlendType.HARDLIGHT.

Signature

def hardlight(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

hue

Show source in blend.py:259

BlendType.HUE.

Signature

def hue(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

imageFloatToInt

Show source in blend.py:384

Convert a numpy array representing an image to an array of ints.

Arguments


  • image np.ndarray - numpy array of floats

Returns


  • np.ndarray - numpy array of ints

Signature

def imageFloatToInt(image: np.ndarray) -> np.ndarray: ...

imageIntToFloat

Show source in blend.py:369

Convert a numpy array representing an image to an array of floats.

Arguments


  • image np.ndarray - numpy array of ints

Returns


  • np.ndarray - numpy array of floats

Signature

def imageIntToFloat(image: np.ndarray) -> np.ndarray: ...

lighten

Show source in blend.py:97

BlendType.LIGHTEN.

Signature

def lighten(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

luminosity

Show source in blend.py:274

BlendType.LUMINOSITY.

Signature

def luminosity(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

multiply

Show source in blend.py:38

BlendType.MULTIPLY.

Signature

def multiply(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

negation

Show source in blend.py:92

BlendType.NEGATION.

Signature

def negation(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

normal

Show source in blend.py:32

BlendType.NORMAL.

Signature

def normal(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

overlay

Show source in blend.py:78

BlendType.OVERLAY.

Signature

def overlay(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

pinlight

Show source in blend.py:151

BlendType.PINLIGHT.

Signature

def pinlight(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

reflect

Show source in blend.py:62

BlendType.REFLECT.

Signature

def reflect(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

saturation

Show source in blend.py:264

BlendType.SATURATION.

Signature

def saturation(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

screen

Show source in blend.py:107

BlendType.SCREEN.

Signature

def screen(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

softlight

Show source in blend.py:120

BlendType.SOFTLIGHT.

Signature

def softlight(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

srcatop

Show source in blend.py:351

Place the layer below above the 'layer above' in places where the 'layer above' exists.

Signature

def srcatop(
    backgroundAlpha: np.ndarray,
    foregroundAlpha: np.ndarray,
    backgroundColour: np.ndarray,
    foregroundColour: np.ndarray,
) -> tuple[np.ndarray, np.ndarray]: ...

vividlight

Show source in blend.py:158

BlendType.VIVIDLIGHT.

Signature

def vividlight(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...

xor

Show source in blend.py:112

BlendType.XOR.

Signature

def xor(background: np.ndarray, foreground: np.ndarray) -> np.ndarray: ...