Well I have found the solution to my problem. When I have an initial image in 2D and a labek image as a result of the segmentaion. In order to add the contour of the label image in the initial image, I type the followings....<br>
<br><br>///////// code /////////////<br> typedef itk::Image<unsigned char, 2> ImageType;<br> ImageType::Pointer image1 = ImageType::New();<br> ImageType::Pointer image_label = ImageType::New();<br> <br> typedef unsigned char InternalPixelType_add;<br>
const unsigned int Dimension = 2;<br> typedef itk::Image< InternalPixelType_add, Dimension > InternalImageType_add;<br> typedef itk::ImageFileReader< InternalImageType_add > ReaderType_add;<br>
<br> ReaderType_add::Pointer reader1 = ReaderType_add::New();<br> reader1->SetFileName( fileName.toStdString() );<br> reader1->Update();<br> image1 = reader1->GetOutput();<br><br> ReaderType_add::Pointer reader2 = ReaderType_add::New();<br>
reader2->SetFileName( "result.png" );<br> reader2->Update();<br> image_label = reader2->GetOutput();<br><br><br> typedef itk::RGBPixel<unsigned char> RGBPixelType;<br> typedef itk::Image<RGBPixelType> RGBImageType;<br>
<br> typedef itk::LabelOverlayImageFilter<ImageType, ImageType, RGBImageType> <br> LabelOverlayImageFilterType;<br> LabelOverlayImageFilterType::Pointer labelOverlayImageFilter = LabelOverlayImageFilterType::New();<br>
labelOverlayImageFilter->SetInput(image1);<br> labelOverlayImageFilter->SetLabelImage(image_label);<br> // labelOverlayImageFilter->SetOpacity(.5);<br> labelOverlayImageFilter->SetOpacity(1.0);<br> labelOverlayImageFilter->ResetColors(); // reset color map<br>
labelOverlayImageFilter->AddColor(0, 0, 255); // fill color map with blue<br> labelOverlayImageFilter->SetBackgroundValue(0); // don't overlay the background, i.e., label 0<br> labelOverlayImageFilter->Update();<br>
<br> typedef itk::ImageFileWriter< RGBImageType > WriterType;<br> WriterType::Pointer writer = WriterType::New();<br> writer->SetFileName("output.png");<br> writer->SetInput(labelOverlayImageFilter->GetOutput());<br>
writer->Update();<br><br> destroyed(ui->graphicsView_resultImage);<br> ui->graphicsView_resultImage->setScene(scene_result=new Canvas());<br> QPixmap tmpmap (QPixmap("output.png"));<br> pixmapItem_result = scene_result->addPixmap (tmpmap.scaled (ui->graphicsView_resultImage->width(),ui->graphicsView_resultImage->height()));<br>
ui->graphicsView_resultImage->setScene(scene_result);<br><br><div class="gmail_quote">2011/6/29 john smith <span dir="ltr"><<a href="mailto:mkitkinsightuser@gmail.com">mkitkinsightuser@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Could somebody explain what exactly do itkLabelOverlayImageFilter? I have written the following code but still I get this
error <br><div><i> error C2296: '%' : illegal, left operand has type 'const float'<br>
</i><br></div>I hope somebody could help.<br>Thanks<i><br><br>////////////////code/////////////////////<br></i><div><i> typedef float InternalPixelType;<br>
const unsigned int Dimension = 2;<br> typedef itk::Image< InternalPixelType, Dimension > InternalImageType;<br> typedef itk::ImageFileReader< InternalImageType > ReaderType;</i><br></div><i><br> ReaderType::Pointer reader1 = ReaderType::New();<br>
reader1->SetFileName( fileName.toStdString() );<br> reader1->Update();<br><br> InternalImageType::Pointer image1 = reader1->GetOutput();<br><br><br> ReaderType::Pointer reader2 = ReaderType::New();<br>
reader2->SetFileName( "result.png" );<br> reader2->Update();<br><br> InternalImageType::Pointer image2 = reader2->GetOutput();<br><br> typedef itk::RGBPixel<unsigned char> RGBPixelType;<br>
typedef itk::Image<RGBPixelType> RGBImageType;<br><br> typedef itk::LabelOverlayImageFilter<InternalImageType, InternalImageType, RGBImageType> LabelOverlayFilterType;<br> LabelOverlayFilterType::Pointer labelOverlayFilter = LabelOverlayFilterType::New();<br>
labelOverlayFilter->SetInput(image1);<br> labelOverlayFilter->SetLabelImage(image2);<br> labelOverlayFilter->SetOpacity(1.0);<br> labelOverlayFilter->ResetColors(); // reset color map<br> labelOverlayFilter->AddColor(0, 0, 255); // fill color map with blue<br>
labelOverlayFilter->SetBackgroundValue(0); // don't overlay the background, i.e., label 0<br> labelOverlayFilter->Update();<br> <br> typedef itk::ImageFileWriter< RGBImageType > WriterType_RGB;<br>
WriterType_RGB::Pointer writer_RGB = WriterType_RGB::New();<br> writer_RGB->SetFileName("addImage.png");<br> writer_RGB->SetInput(labelOverlayFilter->GetOutput());<br> writer_RGB->Update();</i><div style="padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;">
</div>
</blockquote></div><br><div style="visibility: hidden; left: -5000px; position: absolute; z-index: 9999; padding: 0px; margin-left: 0px; margin-top: 0px; overflow: hidden; word-wrap: break-word; color: black; font-size: 10px; text-align: left; line-height: 130%;" id="avg_ls_inline_popup">
</div>