Image Manipulation Toolbox

Version 1.56 (17.7 MB) by DGM
MATLAB Image Manipulation Toolbox
Updated 4 Jul 2024
This library is a loose collection of image manipulation and degradation functions I originally developed as part of a meandering set of 'artistic' hobbies. While I have tried to extend several of the functions toward a more general utility in image editing or analysis, understand that not all of these functions began life with that intention. I post these tools only on the basic assumption that if they have been useful to me, then surely they'll be useful in part to someone else.
This was written and tested in R2009b, R2015b, and R2019b. Some effort has been made to make sure most tools work regardless of MATLAB version.
Only a few files require Image Processing Toolbox, though having IPT is often beneficial. See DEPENDENCIES.txt for notes on replacements for certain IPT functionality.
Let me know if you find bugs.
GUI extensions of several core functions
Passthrough/fallback replacements for several IPT tools
Multi-model color picker GUI
GUI for parametric color-based mask generation
Image viewer with support for alpha and 4D image browsing
Image blending, compositing and masking tools
Color adjustment in various color models
Contrast or chroma enhancement via levels/curves tool (RGB or LAB)
Bidirectional colorspace conversion tools (HSL, HSI, HSY, HSYp, HuSL, HuSLp, LCHab, LCHuv, SRLAB2, OKLAB, YCH, HWB)
Animated GIF import/export tools
4D image array support on many functions
GIMP compatibility in several tools
Documentation with commentary and examples is available at the link above.
cpicktool --interactive color picker GUI
colorpicker --interactively select colors from an image
csview --visualize the projection of RGB in other spaces
imcompare --interactively compare two images (GUI)
imcompose --interactively compose image from layers (GUI)
imgenerate --interactively generate simple images (GUI)
immask --interactively create selections
immodify --interactively modify an image (GUI)
imshow2 --image viewer with transparency & 4D support
batchloader --load arbitrary subsets from a prefixed set of image files
gifread --read animated gif files to 4-D array
gifwrite --write animated gif file from 4-D array
imreadort --read JPG files with correct EXIF orientation
mimread --import an arbitrary selection of image files into a cell array
wpread --read WEBP images
wpwrite --write WEBP images
gettfm --get transformation matrix for luma-chroma models
gmcmyk2rgb --naive conversion between CMYK and RGB
gmrgb2cmyk --naive conversion between RGB and CMYK
hsi2rgb --convert HSI image to sRGB
hsl2rgb --convert HSL image to sRGB
hsy2rgb --convert HSY image to sRGB
husl2rgb --convert HuSL image to sRGB
hwb2rgb --convert HWB image to sRGB
imappmat --apply color transformation matrix
lab2lch --convert rectangular models to polar
lch2lab --convert polar models to rectangular
lch2rgb --convert LCH image to sRGB
linear2rgb --convert linear RGB to sRGB
maxchroma --calculate extent of sRGB in other spaces
rgb2hsi --convert sRGB image to HSI
rgb2hsl --convert sRGB image to HSL
rgb2hsy --convert sRGB image to HSY
rgb2husl --convert sRGB image to HuSL
rgb2hwb --convert sRGB image to HWB
rgb2lch --convert sRGB image to LCH
rgb2linear --convert sRGB to linear RGB
agm --arithmetic-geometric mean
ccmap --return colormaps used by MIMT documentation
circmean --circular mean of angles
chancount --fetch info about image color and alpha channels
colordiff --calculate Delta-E color differences
cp437 --simulate the use of IBM cp437 as utilized by textim()
cshist --color image histogram tool for multiple colorspaces
ctflop --permute a color table to process as an image
ctpath --visualize the trajectory of a colormap in 3D
ctshift --nonlinearly shift the contents of a colormap while preserving the ends
drysize --precalculate output dimensions from imresize()
factor2 --find the factor pairs of an integer
factor3 --find the factor triples of an integer
flipd --version-agnostic wrapper for flip() and flipdim()
fourdee --make non-4D functions work on 4D images
ghm --geometric-harmonic mean
hex2uint --convert prefixed hexadecimal tuples to numeric
im2ct --create a color table from the dominant colors of an image
imcast --convenient typecasting & scaling for images
imclamp --clamp values to within a specified range
imclassrange --get nominal black/white range for a class name
imerror --calculate RMS and mean-square error
imhistFB --grayscale/indexed image histogram tool with more features than IPT imhist()
imrange --return global min and max values from any size array
imrescale --rescale data based on explicit class assertion
imsize --fetch array size independent of dimensionality
imstats --calculate various metrics regarding image colors
intervalct --generate a minimal-length discrete interval colortable
isimageclass --test if image is of an appropriate class
isopaque --test if an image is opaque
issolidcolor --test if an image consists of a single color
ismono --determine if image is monochrome
maketileable --make image size integer-divisible
makect --make a simple 2-point linear color table
matchchannels --make an image and color tuple correspond
matchframes --make two images have the same number of frames
memsize --show the memory footprint of any variable
randisum --random integers with a specified sum
randrange --conveniently generate random numbers in a specified range
roundeven --round/ceil/floor to even integers
roundodd --round/ceil/floor to odd integers
simnorm --simple data normalization
squaresize --aid for resizing a vector into a roughly-square matrix
strismember --see if a string is a member of a set of strings
uint2hexr --convert numeric tuples to prefixed hexadecimal
brline --draw a non-antialiased line or polylines
colorpict --easily produce solid color filled image
fkgen --generate atypical filter kernels
freecb --generate a checkerboard of any size or alignment
imcheckerboard --generate a symmetric checkerboard image
imgenerate --interactively generate simple images (GUI)
imones --generalized version of ones() for all image classes
imzeros --generalized version of zeros() for all image classes
lingrad --two-point or multipoint linear gradient
perlin --create pseudo-perlin noise clouds
perlin3 --create 3-D perlin noise fields
radgrad --two-point or multipoint radial gradient
randlines --create various fields of random lines and walks
randspots --create fields of randomly located shapes
textblock --generate an image of multiline text
textim --generate an image of a single line of text
xwline --create anti-aliased lines or polylines
findpixels --create a mask of pixels relative to a color
immask --interactively create selections (GUI)
mlmask --simple multilevel mask generation
multimask --make mask from a combination of color matches
rangemask --make mask from a combination of color matches
arborddither --multilevel ordered dither with support for arbitrary index arrays
linedither --multilevel dither consisting of variable density line segments
noisedither --binarize image using white or blue noise thresholding
orddither --reduce image using ordered dither
zfdither --reduce image using Zhou-Fang dither
adapthisteqFB --perform CLAHE contrast enhancement
autowb --simple automatic white balance for photos
colorbalance --replicates the GIMP Color Balance tool
gcolorize --replicates the GIMP Colorize tool
ghlstool --replicates the GIMP Hue-Saturation tool
histeqFB --perform histogram equalization
histeqtool --apply histeq()/adapthisteq() to color images in different ways
imadjustFB --passthrough for imadjust with fallback for non-IPT installs
imbcg --basic brightness-contrast-gamma tool with optional GIMP compatibility
imcurves --apply an arbitrary curve to the intensity values
iminv --invert (complement) an image
imlnc --flexible contrast adjustment on I/RGB images
imlnclite --lightweight version of imlnc for use on large images
immodify --interactively modify an image (GUI)
imtweak --adjust channels of an image or color
mixchannels --replicates the GIMP Channel Mixer tool
stretchlimFB --passthrough for stretchlim with fallback for non-IPT installs
tonecmyk --replicates the GMIC CMYK Tone tool
tonergb --replicates the GMIC RGB Tone tool
uwredcomp --adjust underwater photographs for contrast and color compensation
addborder --add a colored border to an image
alphasafe --compose image with checkerboard matting to visualize transparency
alternate --build an image by alternating samples from two or more images
amedfilt --adaptive median noise removal filter
blockify --flexible spatial downsampling of images
bwareafiltFB --select pixel groups based on size
bwdistFB --distance transform for binary images
bwlabelFB --labeling of connected groups
color2alpha --generate alpha from a selected color
colorquant --color quantization using octree decomposition
crop2box --crop a mask to its bounding box
cropborder --easily crop a border from an image
dealternate --undo an alternate() operation
deinterleave --undo an interleave() operation
despeckle --remove small pixel groups
displace --apply a displacement map to an image
dotmask --compare two images using an adjustable mask
edgemap --normalized Scharr filter effect
eoframe --extract every Nth frame from an image set
eoline --erase every n/N lines from an image
extractbg --calculate bg estimate from multiframe image or video
flattenbg --reduce low-frequency image variation
fmedfilt --fixed-window median noise removal filter
gray2rgb --expand an I/IA image to RGB/RGBA
gray2pcolor --convert a grayscale image to a pseudocolored RGB image
hitmiss --hit-miss filter for binary images
icparams --class for image composition parameter objects
imblend --blend two images
imcompose --interactively compose image from layers (GUI)
imcropFB --extract a rectangular ROI from an image
imcropzoom --interactively use IPT imcrop() with less hassle
imdetile --rearrange a flat image into a 4D image stack
imfilterFB --filter/blur an image by convolution/correlation
imgeofilt --geometric mean filter
imhistmatchFB --make an image inherit the intensity distribution of another
immodify --interactively modify an image (GUI)
imnoiseFB --add selected noise type to an image
imrectify --interactively devectorize an image of unknown geometry
imresizeFB --resize an image
imrotateFB --rotate an image
imsharpenFB --perform an unsharp masking operation
imstacker --concatenate dissimilar images on dim 1, 2, or 4
imtile --rearrange a 4D image stack into a flat image
interleave --interleave two or more images along an axis
joinalpha --append an alpha channel to an image or merge with existing alpha
meanlines --create a new image from vector means or extrema
mergedown --merge all frames of a 4-D image
mono --extract a single channel (RGBHSVY)
morphnhood --neighborhood-based morphological operations
morphops --perform morphological operations
nhfilter --nonlinear sliding-window filter operations
padarrayFB --pad the edges of an image
pickblob --return a mask describing the blobs selected by one or more points
ptile --tile a small image to fill a specified geometry
pseudoblurmap --multipass variable-kernel blur approximation
puttext --insert colored or padded text in an image
replacepixels --replace masked pixels with new color or second image
roifilter --restrict the application of a filter by using a mask
splitchans --split a color image into its components
splitalpha --split a color image into its color and alpha components
tonemap --apply tone map to an image
uniquant --convert an array to an index map by uniform quantization
unsharp --sharpen an image using unsharp masking
zblend --use a mask to blend between images in a 4-D array
bicoloradapt --emulate visual adaptation to a damaged CRT display
bwfilmemu --roughly emulate the appearance of various BW film types
continuize --add smoothing to discontinuous image transformations
dilatemargins --selective dilation & erosion on image extrema
driftds --changing superpixel boundaries create the illusion of motion
erraccumulate --generate rounding error maps inefficiently
fdblend --cyclic 4D permutation/blending for imcontfdx
gbcam --emulate the appearance of a photo taken with a GameBoy camera
genknit --generate images of interlocking (knit) curves
glasstiles --create a simple effect like privacy glass
im2ods --encode an image in spreadsheet cells
im2spectrogram --encode an image in audio spectra
imannrotate --rotate an image using simple annular shifting
imcartpol --fun with coordinate mapping
imcontfdx --continuized masked subvector transformation
imcontmip --continuized masked image index permutation
imdestroyer --randomly selected and parameterized image manipulation
imdrag --create subvector smearing effect
imecho --perform frame blending on a 4-D image
imfold --generate an image stack as if repeatedly fan-folding an image
impatmap --convert an image to a grayscale collage of tileable patterns
impatsort --sort and group pattern images by their mean gray level
imrecolor --recolor an image based on the colors of another
imrectrotate --rotate an image using pixel displacement
jellyroll --vectorize an image and then devectorize it in a spiral
jpegger --degrade image with jpeg compression
jpegslur --translate compression error into line displacement
lcdemu --emulate angle-dependence of a bad LCD display
lineshifter --shift lines by vector means of a specified mask
paritysweep --explore parity distribution in a compressed image
patbinchart --visualize the binning performed by impatsort()
permutechannels --permute rgb or hsv channels
picdynamics --LTI system response simulation on image rows
rbdetile --random blockwise detiler
rectds --randomly located rectangles of mean image color
roiflip --flip lines in an area specified by a mask
roishift --shift lines in an area specified by a mask
rotateds --cyclic shifting and downsampling of an image
shuffle --divide image into tiles and permute them
siftpixels --migrate non-nan pixels in a given direction
solarize --apply a solarization effect to an image
straightshifter --shift image channels
text2spectrogram --encode a text marquee in audio spectra
thresholdinpaint --erase and then attempt to fill masked pixels
tonepreset --apply one of several presets for color images
vectorscan --emulate the appearance of a scan processor output
This archive includes all image conversion/blending tools I've submitted to date

Cite As

DGM (2024). Image Manipulation Toolbox (, GitHub. Retrieved .

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!






MIMT/FEX_dependencies/STFT toolbox







MIMT/demo scripts


Version Published Release Notes

See release notes for this release on GitHub:


See release notes for this release on GitHub:

See release notes for this release on GitHub:

See release notes for this release on GitHub:

See release notes for this release on GitHub:

See release notes for this release on GitHub:

See release notes for this release on GitHub:

See release notes for this release on GitHub:

See release notes for this release on GitHub:


See release notes for this release on GitHub:


some bugfixes


some bugfixes
minor improvements
major rewrite of imrescale/imtweak
ADDED: ctshift, rbdetile, ptile + pattern library, impatmap, impatsort, patbinchart, framecount


various bugfixes
complete rewrite of replacepixels()

uwredcomp, gray2rgb, joinalpha, alphasafe, ctpath


added linear RGB blending to lingrad/radgrad
added full I/IA/RGB/RGBA support to gcolorize
other minor bits


some minor improvements

FXF_collection demo script with examples replicating GIMP plugins and GMIC tools using MIMT


various improvements, bugfixes



major rewrite of csview removes colorspace() dependency and GUIDE usage
several new tools
a handful of bug fixes


several bugfixes
several improvements
tidied up code formatting
new fonts for textim()
added: randisum jellyroll imrectify circmean ccmap makect agm ghm splitchans gettfm imgeofilt


some bugfixes
lots of improvements (see CHANGELOG.txt)
added some files




IMPROVED: several files
ADDED: hitmiss morphnhood bwlabelFB despeckle bwdistFB imhistFB histeqFB imhistmatchFB adapthisteqFB

this removes IPT dependency from all but a couple files; see DEPENDENCIES.txt


Added replacements for imresize, imrotate, imfilter, padarray, imcrop, and the basic morphological tools, removing the majority of the remaining dependence on IPT.

also fixed several stupid bugs and improved a few things


textim: added more fonts
added: textblock, cp437, drysize
improved: imblend, imstacker
added lost_bomb_recovery tool for use with imblend


added textim
added imblend modes 'suau dodge' and 'suau burn'

updated description with new docs url


imblend: sped up a couple modes with fast cases, minor synopsis edits
imcompose: consistency fix for some of the new mode changes


assorted bugfixes
minor docs improvement
significant imblend reorganization for correctness and consistency
added imsize, dotmask


lots of bug fixes
starting to fix compatibility issues with newer versions
various improvements

minor update to imblend to add parameterization to the new modes

FIXED: several documentation and demo bugs caused by syntax changes in some tools
class support mode in mono()

IMPROVED: rewrote randlines, perlin
added modes to imblend

ADDED: simnorm()

synopsis edit, as usual


Fixed: 7 tools
Improved: 29 tools
Added: color2alpha, colorpicker, continuize, edgemap, fkgen, imdetile, imtile, imstats, isimageclass, isopaque, issolidcolor, lcmap, maketileable, matchchannels, pseudoblurmap, imrescale


missed a couple files


three new modes added to imblend; other imblend improvements

minor FEX description edit


IMPROVED: imblend, imcompose, mergedown, gif tools, addborder, mono, lch & husl tools, thresholdinpaint, cropborder
ADDED: chancount, icparams, imrectrotate, imannrotate, extractbg, imrecolor, colorquant, imlnclite
various bugfixes


forgot to include the update to imcompose


update to imblend():
added 'softlighteb2', a parametric, symmetric, continuous softlight method


synopsis edit in a file


minor updates to addborder, imblend
typo fixes in imfold, imcartpol


FIXED: stretchlimFB, imcompare, imblend, text2spectrogram, im2spectrogram
IMPROVED: imblend, imcompose, imshow2, ismono
ADDED: memsize

speed improvements to imblend
imcartpol now supports capture of randomized transformations for re-use

attempt to fix description formatting
attempt to fix formatting again
try again
fixed a bug in imshow2 and gifwrite for logical images

displace: added interpolation, cleaned a few things up
imshow2: added 4D support and a stack browsing gui mode
ADDED: imcartpol, mimread, imstacker

FIXED: meanlines, addborder, zfdither
IMPROVED: shuffle, glasstiles, imcompose, randlines, mergedown, immodify
ADDED: randrange, noisedither, imfold, erraccumulate

bugfix in imtweak for 4-D inputs and HSY mode

updated gif tools

BUGFIXES: permutechannels, imcompose, imblend, imlnc, orddither, hsy2rgb
IMPROVED: permutechannels, eoline, imcompose, imblend, immodify, imlnc, gif & gradient tools
ADDED: arborddither, linedither, lcdemu, bicoloradapt, xwline, zblend, imdrag

bugfix in replacepixels
added NaN & OoG view modes and counts
uses linked axes instead of concatenation for 2-up view

updates and bugfixes in image conversion tools
geometry and view control updates to GUI tools (now uses akZoom)
introduction of IMMASK
csview fixed to work in subplots

removed more dependencies:
csview, vectorscan, thresholdinpaint, picdynamics

see DEPENDENCIES.txt for list of IPT and FEX dependencies

removed IPT dependency from MOST tools (see text file)
lots of cleanup, extra class support, etc
updated description

added IPT dependency note
no room left in description
bugfix in imcompose and imgenerate
expanded functionality of imadjust3 and immodify
added more class support to imtweak, imadjust3, others

added Zhou-Fang and ordered dither tools for use with IMBLEND, etc
major updates to imblend and imcompose
minor update to jpegger, imgenerate, immodify

minor imblend update

minor imblend update

added GUI tools (imcompose, imcompare, immodify, imgenerate, cpicktool)
updated imblend, imadjust3, meanlines

updates to imblend, replacepixels, tonemap, and LCH conversion LUT's
smaller package size

removed colorspace dependency from core tools (imblend, imtweak)
expanded and improved imblend and tonemap

updated blend tools

updated imblend() with compositing options

updated 'imblend' with new modes
added contour plot reference for imblend modes

batchloader() now supports images with alpha
imblend() now supports alpha compositing
maxchroma() and RGB-LCH tools now support SRLAB2

updated docs links
code cleanup in sRGB-LCH functions for accuracy & extensibility
added d50 adaptation mode to LCH conversions out of sheer boredom
corrected CSVIEW() plot orientation in CIEXYZ mode

bugfix in maxchroma()
fixes convergence problem in 'labcalc' mode for some images
also did some minor speed optimization

fixed edge convergence inaccuracy in MAXCHROMA() for LAB in direct calculation mode
see manual page or blog for details

bugfix in csview
added alpha adjustment to csview gui tool
moved boundary chroma calculations from LCH and HuSL tools to a standalone function
added tentative direct calculation method for LAB, updated LABLUT.mat with more accurate calculations

removed obsolete dependency check from imtweak
added YPP mode to imtweak for sake of completeness with regard to YPP/HSY, LCH/HuSL symmetry
updated speed benchmarks

modified LCH conversion tools to provide optional data truncation methods
changed IMTWEAK and IMBLEND to use bounded LCH methods
cleaned up IMBLEND color modes
added native modes to HuSL and HSY conversion tools

bugfix in imtweak HSL transfer mode

added HSYp & HSL support to IMBLEND() and cleaned up some dependency checks

added HSYp option to HSY conversion methods
added HSYp support to IMTWEAK()

added HuSLp support to RGB-HuSL converters
added HuSLp and LCHab/uv support to IMTWEAK()

modified description

To view or report issues in this GitHub add-on, visit the GitHub Repository.
To view or report issues in this GitHub add-on, visit the GitHub Repository.