Code covered by the BSD License  

Highlights from
Image overlay

4.32
4.3 | 25 ratings Rate this file 186 Downloads (last 30 days) File Size: 2.09 KB File ID: #10502
image thumbnail

Image overlay

by

Steve Eddins

 

23 Mar 2006 (Updated )

Overlay a binary mask onto an image using a specified color

| Watch this File

File Information
Description

The function IMOVERLAY creates a mask-based image overlay. It takes input image and a binary mask, and it produces an output image whose masked pixels have been replaced by a specified color.

Acknowledgements

This file inspired Neuron Counting, Telo Tool Terminal Restriction Fragment Analysis, Visualization Of Multi Modal Volume Segmentation, Imagescnan.M V2.1 (Aug 2009), Flatten Mask Overlay, and Alphamask: Semi Transparent Image Overlay.

Required Products Image Processing Toolbox
MATLAB release MATLAB 7.2 (R2006a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (35)
05 Aug 2014 Kirtan

Kirtan

Thanks!

25 May 2014 Mohammad Ahmed

Mohammad Ahmed

It was great. Keep up the good work. Thumbs up.

12 Feb 2014 Massimo Ciacci

Massimo Ciacci

 
16 Oct 2013 Steve Eddins

Steve Eddins

Image Analyst, thanks for your comments. I like your suggestion about accepting the output of bwboundaries as the 2nd input argument. I don't really understand your comment about bwperim, though.

Comment only
13 Oct 2013 Image Analyst

Image Analyst

bwperim is not the only way to create outlines. It would be nice if imoverlay were smart enough to see if the input was a binary image, or a cell array that is the output of bwboundaries. A lot of times we threshold and then call bwboundaries. It would be a nice enhancement if it could take the output of bwboundaries as the location of the outlines to draw.

Comment only
22 Jul 2013 Steve Eddins

Steve Eddins

Andrew, you'll have to either pad or resize one of the images to match the other size to overlay them using this function. You could also consider using MATLAB graphics transparency features to overlay one image on another.

Comment only
19 Jul 2013 Andrew

Andrew

Very good tool. Is there any way you can overlay two images that are different sized without one of them becoming dis-formed?

09 Dec 2012 Felix

Felix

I'd like to use this function visualize the clipped pixels (e.g. with value 256 in 8bit grayscale) in red, in the preview of a camera recording.

its possible to apply an arbitrary function to each video frame before its displayed in the preview with this:
setappdata(videoHandle,'UpdatePreviewWindowFcn',@some_function);

however, I havent been able to combine this with imoverlay. Any suggestions??

Comment only
24 Aug 2012 Margarita

Margarita

 
18 Aug 2012 Arash

Arash

 
14 Aug 2012 Sid

Sid

 
21 Apr 2012 supriya

supriya

 
17 Apr 2012 Steve Eddins

Steve Eddins

Lasse - thanks, I have uploaded a new version based on your suggestion.

Comment only
10 Apr 2012 Lasse

Lasse

This might help to some people

out_red(logical(mask)) = color_uint8(1);
out_green(logical(mask)) = color_uint8(2);
out_blue(logical(mask)) = color_uint8(3);

Hope it helps..

05 Mar 2012 Jamuna Jayashri Mahalingam

I am not able to implement it. How should I use this function in my program?

Comment only
10 Dec 2011 Mahmut

Mahmut

 
10 Dec 2011 Mich

Mich

 
09 Mar 2011 Mangesh

Mangesh

 
09 Mar 2011 Mangesh

Mangesh

is it i can find the upper and lower pixel value of my region..............

Comment only
27 Feb 2010 TIAN ZHOU

TIAN ZHOU

thanks. used in my code. will upload soon

06 Nov 2009 James

James

 
03 Aug 2009 hima

hima

This code was great.heyy i want the canny edge borders to be black.now they are in green colour.how to get that???

Comment only
17 Jun 2009 Rotem

Rotem

Great work! saved me some precious time...

Comment only
04 Mar 2009 paddy84

paddy84

This is an excellent bit of code. It worked perfectly fine in my case.

03 Aug 2008 Waleed El-Badry

that's an excellent piece of code.

11 Mar 2008 Carlos Adrián Vargas Aguilera

Great tool. Now I can paint NaN's in black on imagesc.

Thanks

01 Dec 2007 Robert Misevski

Great tool work very well for what a needed to do.

03 Sep 2007 Steve Eddins

Matt - I added a note and an example to the documentation based on your suggestion. Thanks!

Comment only
31 Aug 2007 Phillip SUn

great and loved it

14 Aug 2007 B r  
18 Jul 2007 Matt Whitaker

Simple, useful and well styled and coded. Did something in my existing code similar but this is a bit faster and less memory. Steve, you might want to note in the documentation that if you have a double input outside the range of 0-1 (soemthing you typically use imagesc to display) that you would want to run mat2gray on it before passing to this function. A useful further enhancement would be either to auto detect and apply this or have an optional switch.

14 Jun 2007 Chai Tan

Works great. Saves me a few lines of code! :) Thanks.

28 Apr 2007 Lennart Burg

I think it works great. Thnx

11 Oct 2006 Gil Hornung

I would like to overlay a picture which is not bw.

10 Oct 2006 James Jones

??? Subscript indices must either be real positive integers or logicals.

Error in ==> imoverlay at 54
out_red(mask) = color_uint8(1);

Updates
17 Apr 2012

Based on a suggestion from Lasse, I added code to automatically convert the mask input to be logical.

Contact us