[ITK] [ITK-users] Overlay Woes

Becksfort, Jared Jared.Becksfort at STJUDE.ORG
Thu Jan 25 18:57:04 EST 2018


 Hello,
   Sorry to send this again, but it had the wrong subject.

    I am having some difficulty overlaying boolean masks onto Nifti images. The code below is basically what is shown here (which does work for me when I use the images on the page):. https://itk.org/ITKExamples/src/Filtering/ImageFusion/OverlayLabelMapOnTopOfAnImage/Documentation.html

    The differences that I can see are that I am using 3 dimensions and Nifti float input rather than 2D images of the same pixel and file types (8-bit PNG) in the example.

    Can someone please tell me what I have done wrong?  The output image is garbled beyond recognition.

    Thanks,
    Jared

    const unsigned int Dimension = 3;

    typedef float PixelType;
    typedef unsigned char LabelType;

    typedef itk::Image< PixelType, Dimension > ImageVolumeType;
    typedef itk::Image< LabelType, Dimension > ContourVolumeType;

    typedef itk::ImageFileReader<ContourVolumeType> ContourReaderType;
    typedef itk::ImageFileReader< ImageVolumeType >  ReaderType;

    ReaderType::Pointer reader = ReaderType::New();
    reader->SetFileName( infile1 );

    ContourReaderType::Pointer labelReader = ContourReaderType::New();
    labelReader->SetFileName(infile2);

    typedef itk::LabelObject< LabelType, Dimension > LabelObjectType;
    typedef itk::LabelMap< LabelObjectType > LabelMapType;

    typedef itk::LabelImageToLabelMapFilter< ContourVolumeType, LabelMapType > ConverterType;
    ConverterType::Pointer converter = ConverterType::New();
    converter->SetInput( labelReader->GetOutput() );

    typedef itk::LabelMapOverlayImageFilter< LabelMapType, ImageVolumeType > FilterType;
    FilterType::Pointer filter = FilterType::New();
    filter->SetInput( converter->GetOutput() );
    filter->SetFeatureImage( reader->GetOutput() );
    filter->SetOpacity(0.5);


    typedef itk::ImageFileWriter< FilterType::OutputImageType > WriterType;
    WriterType::Pointer writer = WriterType::New();
    writer->SetFileName(outfile);
    writer->SetInput( filter->GetOutput() );
    writer->Update();




________________________________

Email Disclaimer: www.stjude.org/emaildisclaimer
Consultation Disclaimer: www.stjude.org/consultationdisclaimer
The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
https://itk.org/mailman/listinfo/insight-users


More information about the Community mailing list