[Insight-users] How to get the index for the TriangleMeshToBinaryImageFilter?

Dženan Zukić dzenanz at gmail.com
Wed Jun 30 08:18:20 EDT 2010


Hi Lynx,

that index mentioned in the error message is filter's internal variable. You
cannot set it directly. The most likely cause for that is miscalculation of
your image parameters (origin, size) with regards to mesh's volume. Try
playing with parameters you give to your program to see if it makes a
difference - try smaller mesh, try smaller image, larger image etc.

Regards,
Dženan

On Sun, Jun 20, 2010 at 16:19, <lynx.abraxas at freenet.de> wrote:

> Hello!
>
>
> My  aim is to create a binary image from a vtk-polydata mesh. I found loads
> of
> info to this in the mailinglist archives but still I'm stuck:
> I   want   to   do   it   without    an    input    image    but    let
>  the
> TriangleMeshToBinaryImageFilter  create  one  which  seems  to  be the
> problem
> because my program terminates with:
>
> itk::ExceptionObject (0x811f060)
> Location:        "void
>  itk::TriangleMeshToBinaryImageFilter<TInputMesh,
> TOutputImage>::GenerateData()   [with   TInputMesh   =  itk::Mesh<double,
>  3u,
> itk::DefaultStaticMeshTraits<double,  3u,  3u,  float,   float,   double>
> >,
> TOutputImage = itk::Image<unsigned char, 3u>]"
> File:
>
> /usr/local/include/InsightToolkit/BasicFilters/itkTriangleMeshToBinaryImageFilter.txx
> Line: 224
> Description:  itk::ERROR: TriangleMeshToBinaryImageFilter(0x8119ff0): No
> Image
> Indices Found.
>
> So I wonder how can I supply an index for TriangleMeshToBinaryImageFilter?
>
> Thanks for any help or hints
> Lynx
>
>
>
> ________________________________
>
>
> #include <itkVTKPolyDataReader.h>
> #include <itkTriangleMeshToBinaryImageFilter.h>
> #include <itkImageFileWriter.h>
>
>
>
> int main( int argc, char *argv[] ){
>
>
>    if( argc != 9 )
>        {
>        std::cerr << "Usage: " << argv[0];
>        std::cerr << " input_VTKpolydata-mesh";
>        std::cerr << " outputImage";
>        std::cerr << " dx dy dz ox oy oz";
>        std::cerr << std::endl;
>        return EXIT_FAILURE;
>        }
>
>
>
>    typedef unsigned char  PixelType;
>    const unsigned int    Dimension = 3;
>
>    //typedef itk::DefaultDynamicMeshTraits<double, 3, 3,double,double>
> TriangleMeshTraits;
>    //typedef itk::Mesh<double,3, TriangleMeshTraits> TriangleMeshType;
>
>    //typedef itk::QuadEdgeMesh< float, Dimension >   MeshType;
>
>    typedef itk::Mesh< double, 3 > MeshType;
>
>    typedef itk::Image< PixelType, Dimension >       ImageType;
>
>
>    typedef itk::VTKPolyDataReader<MeshType> VTKmeshreaderType;
>
>    VTKmeshreaderType::Pointer meshReader = VTKmeshreaderType::New();
>    meshReader->SetFileName(argv[1]);
>
>
>   // Set Size, Spacing and origin
>    ImageType::SizeType size;
>    size[ 0 ] = atoi(argv[3]);
>    size[ 1 ] = atoi(argv[4]);
>    size[ 2 ] = atoi(argv[5]);
>
>    ImageType::SpacingType spacing;
>    spacing[0] =  1; //100.0 / size[0];
>    spacing[1] =  1; //100.0 / size[1];
>    spacing[2] =  1; //100.0 / size[2];
>
>    ImageType::PointType origin;
>    origin[0]= atoi(argv[6]);
>    origin[1]= atoi(argv[7]);
>    origin[2]= atoi(argv[8]);
>
>
>    //Set Inside/Outside voxel value
>    const PixelType empty  = 0;
>    const PixelType fill =  255;
>
>
>
>    typedef itk::TriangleMeshToBinaryImageFilter<MeshType, ImageType>
> MeshFilterType;
>    MeshFilterType::Pointer meshFilter = MeshFilterType::New();
>
>    meshFilter->SetInput(meshReader->GetOutput());
>    //meshFilter->SetInfoImage(); //
>    meshFilter->SetTolerance (1.0);
>    meshFilter->SetSize (size);
>    meshFilter->SetSpacing (spacing);
>    meshFilter->SetOrigin(origin);
>    //meshFilter->SetIndex (index);
>    //meshFilter->SetUseObjectValue( true );
>    meshFilter->SetInsideValue(fill);
>    meshFilter->SetOutsideValue(empty);
>
>    //meshFilter->Update();
>
>    // Write the image
>    typedef itk::ImageFileWriter< ImageType >     WriterType;
>    WriterType::Pointer writer = WriterType::New();
>
>    writer->SetFileName(argv[2]);
>    writer->SetInput(meshFilter->GetOutput());
>    try
>        {
>        meshFilter->Update();
>        writer->Update();
>        }
>    catch( itk::ExceptionObject & excp )
>        {
>        std::cerr << excp << std::endl;
>        return EXIT_FAILURE;
>        }
>
>
>    return EXIT_SUCCESS;
>    }
>
>
>
> _____________________________________
> 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.html
>
> 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://www.itk.org/mailman/listinfo/insight-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20100630/dfd9eb53/attachment-0001.htm>


More information about the Insight-users mailing list