Composing multiple BW images to one color image

Composing n binary images to a colored image while each image is layer of some color.

You are now following this Submission

function [c_img] = RGB_layers(imgs,RGBs)

RGB_layers - Visualize n gray/binary images in pseudo color

INPUT: (imgs,RGBs)
imgs: m*k*n matrix. imgs(:,:,i) is a grayscale/BW image.
RGBs: n*3 matrix, each row represents what color the layer will be.
(Optional. By default it will be the jet colormap)

OUTPUT: m*k*3 color image.

EXAMPLE:

I=imread('cameraman.tif');
imgs(:,:,1)=I>180;
imgs(:,:,2)=I<70;
imgs(:,:,3)=mod(I,40)==0;
imgs(:,:,4)=mod(I,70)==0;

RGBs=[1,0,0;0,0.6,0;0,0,1;0.2,0,0.3];
c_img=RGB_layers(imgs,RGBs);
imshow(c_img);

BUG REPORT:
Please send your bug reports, comments and suggestions to
dsilver@tx.technion.ac.il .
Thanks.

Author: David Silver
Department of Computer Science
Technion - Israel Institute of Technology, Haifa, Israel
dsilver@tx.technion.ac.il
Version: 1.00

Cite As

David Silver (2026). Composing multiple BW images to one color image (https://www.mathworks.com/matlabcentral/fileexchange/25973-composing-multiple-bw-images-to-one-color-image), MATLAB Central File Exchange. Retrieved .

Categories

Find more on Modify Image Colors in Help Center and MATLAB Answers

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0