label2color

Version 1.30.0.0 (21.4 KB) by Jing Lou
LABEL2COLOR Convert Label Matrix to RGB Image with specified properties.
179 Downloads
Updated 23 Dec 2015

View License

%LABEL2COLOR Convert Label Matrix to RGB Image with specified properties.
% RGB = LABEL2COLOR(X) converts a label matrix X into a color RGB image
% with default properties for the purpose of visualizing the labeled regions.
%
% RGB = LABEL2COLOR(X,PARAM1,VAL1,PARAM2,VAL2,___) converts a label matrix X,
% specifying parameters and corresponding values that control various aspects of the RGB image.
% Parameter case does not matter.
%
% PROPERTIES can be a comma-separated list of strings
% 'ColorMap' - colormap (default 'jet')
% 'ZeroColor' - zero color (background, uint8/double, default [0 0 0])
% 'EdgeColor' - edge color (uint8/double, default [255 255 255])
% 'EdgeWidth' - edge width (default 1)
%
% Class Support
% -------------
% The input label matrix X can have any numeric class. It must contain
% finite nonnegative integers. RGB is uint8.
%
% Example 1
% ---------
% RGB = label2color(X);
%
% Example 2
% ---------
% RGB = label2color(X,'colormap','summer');
%
% Example 3
% ---------
% RGB = label2color(X,'ColorMap','hot','ZeroColor',[0 0 1],'EdgeColor',[1 1 1],'EdgeWidth',3);
%
%
% 20/12/2015, ver 1.10, modify the code for 'EdgeWidth'
% 21/12/2015, ver 1.20, support any numeric class
% 22/12/2015, ver 1.21, remove 'assignin'
% 22/12/2015, ver 1.22, 'numregion' should plus 1; set default 'ColorMap' to 'jet'
% 22/12/2015, ver 1.23, add demo
% 23/12/2015, ver 1.30, support custom colormap
%
% Jing Lou (楼竞), http://www.loujing.com
%

Cite As

Jing Lou (2024). label2color (https://www.mathworks.com/matlabcentral/fileexchange/54579-label2color), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Modify Image Colors in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.30.0.0

support custom colormap

1.23.0.0

'numregion' should plus 1
set default 'ColorMap' to 'jet'
add demo

1.21.0.0

remove 'assignin'

1.2.0.0

support any numeric class

1.0.0.0

add demo
modify the part of 'edgewidth'