Hi Lynx,<div><br></div><div>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.<br>
<div><br></div><div>Regards,</div><div>Dženan<br><br><div class="gmail_quote">On Sun, Jun 20, 2010 at 16:19, <span dir="ltr"><<a href="mailto:lynx.abraxas@freenet.de">lynx.abraxas@freenet.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hello!<br>
<br>
<br>
My aim is to create a binary image from a vtk-polydata mesh. I found loads of<br>
info to this in the mailinglist archives but still I'm stuck:<br>
I want to do it without an input image but let the<br>
TriangleMeshToBinaryImageFilter create one which seems to be the problem<br>
because my program terminates with:<br>
<br>
itk::ExceptionObject (0x811f060)<br>
Location: "void itk::TriangleMeshToBinaryImageFilter<TInputMesh,<br>
TOutputImage>::GenerateData() [with TInputMesh = itk::Mesh<double, 3u,<br>
itk::DefaultStaticMeshTraits<double, 3u, 3u, float, float, double> >,<br>
TOutputImage = itk::Image<unsigned char, 3u>]"<br>
File:<br>
/usr/local/include/InsightToolkit/BasicFilters/itkTriangleMeshToBinaryImageFilter.txx<br>
Line: 224<br>
Description: itk::ERROR: TriangleMeshToBinaryImageFilter(0x8119ff0): No Image<br>
Indices Found.<br>
<br>
So I wonder how can I supply an index for TriangleMeshToBinaryImageFilter?<br>
<br>
Thanks for any help or hints<br>
Lynx<br>
<br>
<br>
<br>
________________________________<br>
<br>
<br>
#include <itkVTKPolyDataReader.h><br>
#include <itkTriangleMeshToBinaryImageFilter.h><br>
#include <itkImageFileWriter.h><br>
<br>
<br>
<br>
int main( int argc, char *argv[] ){<br>
<br>
<br>
if( argc != 9 )<br>
{<br>
std::cerr << "Usage: " << argv[0];<br>
std::cerr << " input_VTKpolydata-mesh";<br>
std::cerr << " outputImage";<br>
std::cerr << " dx dy dz ox oy oz";<br>
std::cerr << std::endl;<br>
return EXIT_FAILURE;<br>
}<br>
<br>
<br>
<br>
typedef unsigned char PixelType;<br>
const unsigned int Dimension = 3;<br>
<br>
//typedef itk::DefaultDynamicMeshTraits<double, 3, 3,double,double> TriangleMeshTraits;<br>
//typedef itk::Mesh<double,3, TriangleMeshTraits> TriangleMeshType;<br>
<br>
//typedef itk::QuadEdgeMesh< float, Dimension > MeshType;<br>
<br>
typedef itk::Mesh< double, 3 > MeshType;<br>
<br>
typedef itk::Image< PixelType, Dimension > ImageType;<br>
<br>
<br>
typedef itk::VTKPolyDataReader<MeshType> VTKmeshreaderType;<br>
<br>
VTKmeshreaderType::Pointer meshReader = VTKmeshreaderType::New();<br>
meshReader->SetFileName(argv[1]);<br>
<br>
<br>
// Set Size, Spacing and origin<br>
ImageType::SizeType size;<br>
size[ 0 ] = atoi(argv[3]);<br>
size[ 1 ] = atoi(argv[4]);<br>
size[ 2 ] = atoi(argv[5]);<br>
<br>
ImageType::SpacingType spacing;<br>
spacing[0] = 1; //100.0 / size[0];<br>
spacing[1] = 1; //100.0 / size[1];<br>
spacing[2] = 1; //100.0 / size[2];<br>
<br>
ImageType::PointType origin;<br>
origin[0]= atoi(argv[6]);<br>
origin[1]= atoi(argv[7]);<br>
origin[2]= atoi(argv[8]);<br>
<br>
<br>
//Set Inside/Outside voxel value<br>
const PixelType empty = 0;<br>
const PixelType fill = 255;<br>
<br>
<br>
<br>
typedef itk::TriangleMeshToBinaryImageFilter<MeshType, ImageType> MeshFilterType;<br>
MeshFilterType::Pointer meshFilter = MeshFilterType::New();<br>
<br>
meshFilter->SetInput(meshReader->GetOutput());<br>
//meshFilter->SetInfoImage(); //<br>
meshFilter->SetTolerance (1.0);<br>
meshFilter->SetSize (size);<br>
meshFilter->SetSpacing (spacing);<br>
meshFilter->SetOrigin(origin);<br>
//meshFilter->SetIndex (index);<br>
//meshFilter->SetUseObjectValue( true );<br>
meshFilter->SetInsideValue(fill);<br>
meshFilter->SetOutsideValue(empty);<br>
<br>
//meshFilter->Update();<br>
<br>
// Write the image<br>
typedef itk::ImageFileWriter< ImageType > WriterType;<br>
WriterType::Pointer writer = WriterType::New();<br>
<br>
writer->SetFileName(argv[2]);<br>
writer->SetInput(meshFilter->GetOutput());<br>
try<br>
{<br>
meshFilter->Update();<br>
writer->Update();<br>
}<br>
catch( itk::ExceptionObject & excp )<br>
{<br>
std::cerr << excp << std::endl;<br>
return EXIT_FAILURE;<br>
}<br>
<br>
<br>
return EXIT_SUCCESS;<br>
}<br>
<br>
<br>
<br>
_____________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href="http://www.kitware.com/products/protraining.html" target="_blank">http://www.kitware.com/products/protraining.html</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.itk.org/mailman/listinfo/insight-users" target="_blank">http://www.itk.org/mailman/listinfo/insight-users</a><br>
</blockquote></div><br></div></div>