<div><br></div>Hi James,<div><br></div><div><br></div><div>There are three easy methods for coloring an image of labels.</div><div><br></div><div><br></div><div>Method A:</div><div><br></div><div>    Use the method illustrated in the example:</div>
<div><br></div><div>            Insight/Examples/Segmentation/WatershedSegmentation1.cxx</div><div><br></div><div>    namely:</div><div><br></div><div><div>  typedef itk::Functor::ScalarToRGBPixelFunctor<unsigned long></div>
<div>    ColorMapFunctorType;</div><div>  typedef itk::UnaryFunctorImageFilter<LabeledImageType,</div><div>    RGBImageType, ColorMapFunctorType> ColorMapFilterType;</div><div>  ColorMapFilterType::Pointer colormapper = ColorMapFilterType::New();</div>
<div><br></div></div><div><br></div><div><br></div><div>Method B:</div><div><br></div><div>    Use the tkScalarToRGBColormapImageFilter.h class in the</div><div>    directory:</div><div><br></div><div>               Insight/Code/Review</div>
<div><br></div><div>     This filter is described in the following Insight Journal paper:</div><div><br></div><div>           <a href="http://www.insight-journal.org/browse/publication/285">http://www.insight-journal.org/browse/publication/285</a></div>
<div><br></div><div><br></div><div><br></div><div><br></div><div>Method C:</div><div><br></div><div>     Use the filter </div><div><br></div><div>              Insight/Code/Review/</div><div>                      itkLabelToRGBImageFilter.h</div>
<div><br>      that is described in the Insight Journal paper:</div><div><br></div><div>                <a href="http://www.insight-journal.org/browse/publication/176">http://www.insight-journal.org/browse/publication/176</a></div>
<div><br></div><div><br></div><div><br></div><div>If you are planning on doing extensive work with labeled images,</div><div>you may want to use Method C, and get familiar with the associated</div><div>Insight Journal paper, since it provides a very rich collection of classes</div>
<div>and filters for dealing with labeled images.</div><div><br></div><div><br></div><div>          Regards,</div><div><br></div><div><br></div><div>                Luis</div><div><br></div><div><br></div><div>--------------------------------------------------------------------------------------<br>
<div class="gmail_quote">On Thu, Dec 3, 2009 at 5:36 AM, Malsoaz James <span dir="ltr"><<a href="mailto:jmalsoaz@yahoo.fr">jmalsoaz@yahoo.fr</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<table cellspacing="0" cellpadding="0" border="0"><tbody><tr><td valign="top" style="font:inherit">Hello, I'm trying to label a binary image. For that, I have been using ConnectedComponentImageFilter and RelabelComponentImageFilter with no problem apparently.<br>
<br>I'm able to get the number of objects and the size of them. But I can't figure out how to display the objects found in the image with different levels of gray (prefered solution) or different colors. Indeed, I'm getting an almost black image where I can difficultly distinguish the objects.<br>
<br>I would really appreciate some help to solve this.<br>Thank you.<br>James<br><br>By the way, here is my code:<br><br>typedef unsigned char PixelType;<br>typedef itk::Image<PixelType, 2> ImageType;<br>typedef itk::ImageFileReader<ImageType> ReaderType;<br>
typedef itk::ImageFileWriter<ImageType> WriterType;<br>typedef itk::ConnectedComponentImageFilter <ImageType, ImageType>
 LabelType;<br>typedef itk::RelabelComponentImageFilter <ImageType, ImageType> RelabelType;<br><br><br>int main(int argc, char *argv[])<br>{<br>    ReaderType::Pointer reader = ReaderType::New();<br>    WriterType::Pointer writer = WriterType::New();<br>
    LabelType::Pointer labeler = LabelType::New();<br>    RelabelType::Pointer relabeler = RelabelType::New();<br><br>    reader->SetFileName("input.bmp");<br><br>    labeler->SetInput(reader->GetOutput());<br>
    labeler->Update();<br><br>    relabeler->SetInput(labeler->GetOutput());<br>    relabeler->Update();<br><br>    for (unsigned int i=0; i<relabeler->GetNumberOfObjects(); i++)<br>    {<br>        std::cout<<"Number of pixel for object "<<i<<":
 "<<relabeler->GetSizeOfObjectsInPixels()[i]<<std::endl;<br>    }<br>    writer->SetFileName("output.bmp");<br>    writer->SetInput(relabeler->GetOutput());<br>    writer->Update();<br>
    return EXIT_SUCCESS;<br><br>}<br></td></tr></tbody></table><br>
      <br>_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
<br></blockquote></div><br></div>