[Insight-users] ScalarToRGBPixelFunctor maps too similar colors

bear xiongguanglei at tsinghua.org.cn
Tue May 24 14:57:12 EDT 2005


when label number is small
MIME-Version: 1.0
Content-Type: multipart/mixed;
	boundary="----=_1116961032_12909.attach"

------=_1116961032_12909.attach
Content-Type: text/plain

hi Luis,
   Thanks for your elaborate explanations. I have implemented my own label2color
mapper with some sort of randomness in RGB channels. It looks acceptable. Thanks
again!
   
   Another question: 
   I think function HysteresisThresholding() and FollowEdge() in
CannyEdgeDetectionImageFilter can be simplified:
(1) check if we need to followedge in HysteresisThresholding();
(2) only change mark when poping out from the list
The corresponding changes in two functions is attached.
   BTW, I find canny sometimes produces edges in a disconnected form. In
documents, I see "Edge-linking will be added when an itk connected component
labeling algorithm is available." Can this edge-linking partially resolve this
problem? When will it be available?
 
                                             bear   

In your mail:
>From: Luis Ibanez <luis.ibanez at kitware.com>
>Reply-To: 
>To: ??? <xiongguanglei at tsinghua.org.cn>
>Subject: Re: [Insight-users] ScalarToRGBPixelFunctor maps too similar colors
when label number is small
>Date:Tue, 24 May 2005 11:52:51 -0400
>
>
> 
> Hi Xiong
> 
> 
> This Functor generate a hash table of colors
> and associate them to the input labels.
> 
> The algorithm is intended to deal with large
> numbers of labels, and it is based on using the
> low bits of the label in order to chose the colors.
> 
> 
> The output RGB values are controled by a hashing
> scheme that uses the individual bytes of the
> input label.
> 
> 
> You may want to "retouch" the hashing scheme,
> or simply resort your labels so they don't have
> close numerical values.
> 
> 
> Note that this is an Ill-posed problem. There is
> not a clear way to guarrantee that colors will
> be different enough.
> 
> The formal way in which this could be done in
> colorimetry is by taking the N labels that you
> need and throwing them in RGB space using a
> code-spreading algorithm.  You will find such
> algorithms described in texts such as Graphic
> Gems, and if you want to go to the powerful
> and sophisticated ones, you could go for
> 
> "Sphere Packing Lattice and Groups"
> by Convway and Sloane
> Springer Verlag
> 1993
> http://www.amazon.com/exec/obidos/ASIN/0387985859/qid=1116949852/sr=2-1/ref=pd_bbs_b_2_1/104-5891421-3507160
> 
> 
> 
> 
> Please let us know if you have further questions,
> 
> 
>     Thanks
> 
> 
>        Luis
> 
> 
> 
> --------------------------------------------------
> ??? wrote:
> 
> > hi all,
> >     I use ScalarToRGBPixelFunctor to map labels to colors. When label number
> > is large, about several hundreds, it is good. But when label number is small,
> > about several tens, it map to similar colors, most of green. Why?
> >                                                  bear
> > 
> > 
> > _______________________________________________
> > Insight-users mailing list
> > Insight-users at itk.org
> > http://www.itk.org/mailman/listinfo/insight-users
> > 
> > 
> 
> 
> 
>



------=_1116961032_12909.attach
Content-Type: text/x-c++src;
	name="canny.cxx"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
	filename="canny.cxx"

dGVtcGxhdGU8IGNsYXNzIFRJbnB1dEltYWdlLCBjbGFzcyBUT3V0cHV0SW1hZ2UgPgp2b2lk
CkNhbm55RWRnZURldGVjdGlvbkltYWdlRmlsdGVyPCBUSW5wdXRJbWFnZSwgVE91dHB1dElt
YWdlID4KOjpIeXN0ZXJlc2lzVGhyZXNob2xkaW5nKCkKewogIHR5cGVuYW1lIE91dHB1dElt
YWdlVHlwZTo6UG9pbnRlciBvdXRwdXQgPSB0aGlzLT5HZXRPdXRwdXQoKTsKICBmbG9hdCB2
YWx1ZTsKCiAgTGlzdE5vZGVUeXBlICpub2RlOwoKICBJbWFnZVJlZ2lvbkl0ZXJhdG9yPFRP
dXRwdXRJbWFnZT4gb2l0KG91dHB1dCwgb3V0cHV0LT5HZXRSZXF1ZXN0ZWRSZWdpb24oKSk7
CiAgCiAgb2l0LkdvVG9CZWdpbigpOwogIAogIEltYWdlUmVnaW9uSXRlcmF0b3I8VE91dHB1
dEltYWdlPiB1aXQobV9VcGRhdGVCdWZmZXIsCiAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICBtX1VwZGF0ZUJ1ZmZlci0+R2V0UmVxdWVzdGVkUmVnaW9uKCkpOwog
IHVpdC5Hb1RvQmVnaW4oKTsKICB3aGlsZSghdWl0LklzQXRFbm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4KG5JbmRleCk7CiAgICAgIGlmKEluQm91bmRzKG5J
bmRleCkpCiAgICAgICAgewogICAgICAgIGlmKG9pdC5HZXRQaXhlbChpKSA+IG1fTG93ZXJU
aHJlc2hvbGQgJiYgdWl0LlZhbHVlKCkgIT0gMSAgKQogICAgICAgICAgewogICAgICAgICAg
bm9kZSA9IG1fTm9kZVN0b3JlLT5Cb3Jyb3coKTsgIC8vIGdldCBhIG5ldyBub2RlIHN0cnVj
dAogICAgICAgICAgbm9kZS0+bV9WYWx1ZSA9IG5JbmRleDsgICAgICAgIC8vIHNldCBpdHMg
dmFsdWUKICAgICAgICAgIG1fTm9kZUxpc3QtPlB1c2hGcm9udChub2RlKTsgICAvLyBhZGQg
dGhlIG5ldyBub2RlIHRvIHRoZSBsaXN0CiAgICAgICAgICB9CiAgICAgICAgfQogICAgICB9
CiAgICB9Cn0KCg==

------=_1116961032_12909.attach--



More information about the Insight-users mailing list