[ITK] [ITK-users] LabelGeometryImageFilter: empty output of GetOrientedLabelImage and GetOrientedIntensityImage
Bill Lorensen
bill.lorensen at gmail.com
Mon Apr 6 02:02:02 EDT 2015
Thomas,
I compiled your program and ran it on one of my labeled images and it
produces the expected output.
On Sun, Apr 5, 2015 at 2:52 PM, Thomas Seidel <seidel at cvrti.utah.edu> wrote:
> Hi Bill,
>
> Thanks for your answer. Here is (part of the) source I am using.
> Do you need the image or source files?
>
>
>
>
> #include "itkImage.h"
> #include "itkImageFileReader.h"
> #include "itkImageFileWriter.h"
> #include "itkLabelGeometryImageFilter.h"
>
> #include "itksys/SystemTools.hxx"
>
> #include <sstream>
>
>
> int main(int argc, char * argv[])
> {
> // Verify command line arguments
> if( argc < 2 )
> {
> std::cerr << "Usage: " << std::endl;
> std::cerr << argv[0] << " InputImageFile [-intensity
> <IntensityImageFile>]" << std::endl;
> return EXIT_FAILURE;
> }
> std::string inputFilename = argv[1];
> std::string intensityFile;
> bool calcIntensity = false;
>
>
> int argcounter = 2;
> while (argc>argcounter)
> {
> if (!strncmp(argv[argcounter],"-intensity",10) ) {intensityFile =
> argv[argcounter + 1]; calcIntensity = true; }
> argcounter++;
> }
>
> // Setup types
> typedef itk::Image<unsigned int, 3> IntImageType;
> typedef itk::Image<float, 3> FloatImageType;
> typedef itk::ImageFileReader<IntImageType> ReaderType;
> typedef itk::ImageFileReader<FloatImageType>
> FloatReaderType;
>
> ReaderType::Pointer reader = ReaderType::New();
> reader->SetFileName( inputFilename );
> FloatReaderType::Pointer FloatReader = FloatReaderType::New();
>
>
>
> typedef itk::LabelGeometryImageFilter< IntImageType, FloatImageType >
> LabelGeometryImageFilterType;
> LabelGeometryImageFilterType::Pointer labelGeometryImageFilter =
> LabelGeometryImageFilterType::New();
> labelGeometryImageFilter->SetInput( reader->GetOutput() );
>
>
> if (calcIntensity)
> {
> FloatReader->SetFileName(intensityFile);
> FloatReader->Update();
> labelGeometryImageFilter->SetIntensityInput(FloatReader->GetOutput());
> labelGeometryImageFilter->CalculateOrientedIntensityRegionsOn();
>
> }
>
>
> labelGeometryImageFilter->CalculatePixelIndicesOn();
> labelGeometryImageFilter->CalculateOrientedBoundingBoxOn();
> labelGeometryImageFilter->CalculateOrientedLabelRegionsOn();
>
> labelGeometryImageFilter->Update();
>
> LabelGeometryImageFilterType::LabelsType allLabels =
> labelGeometryImageFilter->GetLabels();
> LabelGeometryImageFilterType::LabelsType::iterator allLabelsIt;
> std::cout << "Number of labels: " <<
> labelGeometryImageFilter->GetNumberOfLabels() << std::endl;
> std::cout << std::endl;
>
>
>
> for( allLabelsIt = allLabels.begin(); allLabelsIt != allLabels.end();
> allLabelsIt++ )
> {
>
> LabelGeometryImageFilterType::LabelPixelType labelValue = *allLabelsIt;
>
>
> std::ostringstream stream;
> stream << labelValue << ".vtk";
> typedef itk::ImageFileWriter<IntImageType> WriterType;
> WriterType::Pointer writer = WriterType::New();
> writer->SetFileName(stream.str());
> writer->SetInput(labelGeometryImageFilter->GetOrientedLabelImage(labelValu
> e));
> writer->Update();
>
> std::ostringstream stream2;
> stream2 << labelValue << "-intensity.vtk";
>
> if (calcIntensity) {
> typedef itk::ImageFileWriter<FloatImageType> FloatWriterType;
> FloatWriterType::Pointer Floatwriter = FloatWriterType::New();
> Floatwriter->SetFileName(stream2.str());
> Floatwriter->SetInput(labelGeometryImageFilter->GetOrientedIntensityImage
> (labelValue));
> Floatwriter->Update();
> }
> }
>
>
>
>
>
>
> return EXIT_SUCCESS;
> }
>
>
>
>
>
>
> On 4/5/15 12:10 PM, "Bill Lorensen" <bill.lorensen at gmail.com> wrote:
>
>>Do you have a small, compilable example that illustrates the problem?
>>
>>On Sun, Apr 5, 2015 at 10:09 AM, Thomas Seidel <seidel at cvrti.utah.edu>
>>wrote:
>>> Hi all,
>>>
>>> I am using the itkLabelGeometryImageFilter to get information about the
>>> orientation of labeled objects.
>>> I provide a LabelImage and a IntensityImage.
>>> I set CalculateOrientedLabelRegionsOn() and
>>> CalculateOrientedIntensityRegionsOn().
>>>
>>> However, when I use
>>> writer->SetInput(filter->GetOrientedLabelImage());
>>> writer->Update();
>>> or
>>> writer->SetInput(filter->GetOrientedIntensityImage());
>>> writer->Update();
>>>
>>> it just generates empty images (all values 0) with the size of the
>>>oriented
>>> bounding box.
>>>
>>> Is this how the filter is supposed to work?? I was expecting the rotated
>>> labels and the rotated region of the intensity image defined by the
>>>oriented
>>> bounding box, respectively.
>>>
>>> Thanks,
>>> Thomas
>>>
>>> _____________________________________
>>> 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:
>>> http://public.kitware.com/mailman/listinfo/insight-users
>>>
>>
>>
>>
>>--
>>Unpaid intern in BillsBasement at noware dot com
>
>
>
--
Unpaid intern in BillsBasement at noware dot com
_____________________________________
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:
http://public.kitware.com/mailman/listinfo/insight-users
More information about the Community
mailing list