<table cellspacing="0" cellpadding="0" border="0" ><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></table><br>