Create a color overlay of two images. Allows transparency and thresholding.
Updated 22 Apr 2015

View License

IMOVERLAY allows you to easily display one image in color on top of another grayscale image. You can independently control the clim of each image, the colormap used for the top image, and the transparency. Resulting image can be displayed in a separate figure or in a supplied axis.
IMOVERLAY_TOOL is an interface to graphically overlay one image on top of another and manipulate colormap, thresholding, and transparency.
- Allows independent control of both images
- Workspace variables are selected via a dropdown menu
- Easily adjust colormap
- Adjustable transparency
- Load 3D or 4D datasets
- Export figure for saving
- Accelerator keys for quick selections

% Overlay one image transparently onto another
imB = phantom(256); % Background image
imF = rgb2gray(imread('ngc6543a.jpg')); % Foreground image
[hf,hb] = imoverlay(imB,imF,[40,180],[0,0.6],'jet',0.6);
colormap('hot'); % figure colormap still applies

% Use the interface for flexibility

Cite As

Matt Smith (2024). imoverlay (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014b
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!
Version Published Release Notes

01/02/2015 ensure compatibility with Matlab 2014b.
4/22/15 added fix if initial image is all zeros (thanks Isabel!)

1/2/15 - changed default colormap to parula just to follow Mathworks, changed button color for Macs so it'll display properly, updated compatibility for 2014b

03/30/2014 - Fixed bug reported by user Matt J (thanks!). When supplying an existing axes to put the image overlay, the user supplied colormap will be applied to the new figure.