These tools effect image blending and masking functionality common in image manipulation applications such as GIMP. For a layered image composition GUI based on this functionality, see the parent toolbox linked below.
================== BLENDING FUNCTION ==================
IMBLEND() can blend images or imagesets as one would blend layers in GIMP or Photoshop. See 'help imblend'
I assert that if nothing else, IMBLEND() stands as the single most comprehensive collection and demonstration of blend mode math from GIMP, ImageMagick, Photoshop, Krita, and elsewhere.
Inputs are image arrays of same H,V dimension; both can be single images or 4-D imagesets of equal length.
-- Mismatches of dimensions 1:2 are not supported. Use IMRESIZE, IMCROP, or PADARRAY
to enforce desired colocation of layer content.
-- Mismatches of dimension 3 are handled by array expansion.
1 or 3 channel images are assumed to be monochrome or RGB, respectively
2 or 4 channel images are assumed to have an added alpha channel
blending a RGB image and a monochrome image results in an RGB image
blending a I/RGB image with a IA/RGBA image results in an image with alpha
-- Mismatches of dimension 4 are handled by array expansion.
both can be single images or 4-D imagesets of equal length
can also blend a single image with a 4-D imageset
User can optionally specify compositing method independently of the blend method.
Most blend and composition modes are controllable via an AMOUNT parameter. This may internally scale the influence of blends in a manner which cannot be acheived using mixdown opacity, or may control density/thresholding behavior in composition modes.
gimp compatibility (default)
dissolve (6 variants)
==== Light & Contrast ====
softlight (5 variants)
soft flat light
==== Quadratic & Complements ====
==== Niche Krita/EB Modes ====
==== Dodge & Burn ====
==== Relational ====
==== Mathematic ====
==== Mesh Modes ====
==== Component ====
color (5 variants)
transfer inchan>outchan (directly transfer any channel to another)
permute inchan>H (rotate hue)
permute inchan>HS (rotate hue and blend saturation)
================== MASKING FUNCTION ==================
Also included is REPLACEPIXELS() which effects an opacity blending similar to GIMP's 'Layer Mask' functionality. Accepts two input images and a mask. Foreground image may be replaced by a color triplet for convenience. REPLACEPIXELS() supports multichannel and multiframe masks, and can support NaN throughput if mask is logical.
Archive includes support functions for image conversion and typecasting. Extra toolboxes should not be required.
Submission thumbnail shows contour plots for the majority of the non-component blend modes. Included in the zip file is a PDF containing this sheet as well as parameter sweeps for select modes.
Documentation with commentary, example code, and input/output images is available here:
This is part of my image manipulation toolbox:
added 'softlighteb2', a parametric version of the most correct 'softlight' variant
try again to update screenshot
added 'soft flatlight', 'easylight'
Typo fixes in synopsis, indentation fixes.
bugfix for 'hardbomb' when verbose
faster for single-frame images (all modes) (avg 160% faster in R2015b)
minor update to supporting files
Added Krita/EB/etc modes: softlightps, softlighteb, light, shadow, bright, dark, lighteneb, darkeneb, bleach, stain, sqrtdiff, invsqrtdiff, gammalight, gammadark, arctan, harmonic, bomblocked
fixed archive contents
bugfix in replacepixels for certain images with NaNs and logical masks
update to support functions for image conversion
Noted removal of BLENDMASK in description
removed IPT dependency
better, controllable error messaging
updated description text
fixed a stupid bug in darkenrgb for nonunity parameter
added dissolve mode
added or improved:
added, updated, or parameterized:
added or improved modes:
Added several modes.
Added composite-only blend modes
fixed a conditional which forced RGB mode for 'color dodge'
updated RGB-LCH conversion tools,
updated docs links
code cleanup in sRGB-LCH functions for accuracy & extensibility
updated maxchroma() for consistency
updated HuSL and LCH conversion tools
removed useless color blend modes
bugfix in the HSL transfer modes
added HSYp support
added link to web manual
Added support for expanded HuSL methods.
added support for HuSL methods; see submission #53423
increased 'color lch' speed by 20%, added example image sheet to demonstrate 'color' modes
expanded 'color' blend mode selection and clarified GIMP/Photoshop compatibility
removed an unforeseen dependency
added other color blend modes
added legacy colorhsv mode
added HSI conversion methods to work around issues with colorspace()
added a few more modes to the 'permute' mode as I needed them
this description editor is unforgivably bad
added arbitrary channel transfer mode and made 'permute' code more flexible for possible generalization
massaged the description
fixed a range-enforcement bug in the quadratic modes
fixed a tiny bug with NaN handling in some modes, added 'contrast' blend mode
added more blend modes to imblend.m and made blendmask.m flexible along dim 3
actually uploaded the correct file
tidied up some description and fixed the thumbnail
added masking functions
added thumbnail image
my kingdom for a post editor that works
trying to format description text
Inspired by: Colorspace Transformations