Thread Subject: Label2rgb

Subject: Label2rgb

From: Torvald Helmer

Date: 3 Jun, 2008 14:50:19

Message: 1 of 3

Hi,

I have a binary image that I want two colorize. It has
several objects in it. The label2rgb have preset colormaps.

How can I set my own colors for each label? Do I have to
make my own colormap? How do I do this?

Subject: Label2rgb

From: us

Date: 3 Jun, 2008 15:03:03

Message: 2 of 3

"Torvald Helmer":
<SNIP tired of stock-maps...

> How can I set my own colors for each label? Do I have to
> make my own colormap? How do I do this...

colormaps are simply matrices of the form
     ncol x [R,G,B]
where RGBs are values [0,1]
eg,

% the color map
     ncol=128;
% - eg,
     cmap=[
          ones(ncol,1),...
         (1:ncol).'./ncol,...
         (ncol:-1:1).'./ncol
     ];
% - add some black noise
     rix=randperm(ncol);
     cmap(rix(1:10),:)=0;
% show what we have
     colormap(cmap);
     colorbar;
% now, use <cmap> in your call to label2rgb

us

Subject: Label2rgb

From: Steve Eddins

Date: 3 Jun, 2008 15:34:06

Message: 3 of 3

Torvald Helmer wrote:
> Hi,
>
> I have a binary image that I want two colorize. It has
> several objects in it. The label2rgb have preset colormaps.
>
> How can I set my own colors for each label? Do I have to
> make my own colormap? How do I do this?

You can specify your own colormap in the call to label2rgb:

Syntaxes:

RGB = label2rgb(L)
RGB = label2rgb(L, map)
RGB = label2rgb(L, map, zerocolor)
RGB = label2rgb(L, map, zerocolor, order)

Doc:

http://www.mathworks.com/access/helpdesk/help/toolbox/images/label2rgb.html

---
Steve Eddins
http://blogs.mathworks.com/steve/

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
indexing us 3 Jun, 2008 11:05:22
code us 3 Jun, 2008 11:05:22
colormap us 3 Jun, 2008 11:05:22
colorbar us 3 Jun, 2008 11:05:22
randperm us 3 Jun, 2008 11:05:22
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com