<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2800.1528" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi!</FONT></DIV>
<DIV><FONT face=Arial size=2> I'm working on a simple example
to read a RAW 2D image with VTK, then exporting it to ITK and writing it as a
PNG file. I couldn't find the class itkImageToVTKImageFilter that everyone is
talking about, so I used the function defined at
itk\applications\\connectVTKToITK. The program compiles, links, but when I call
the Print() method on the ITK importer it says its got "No Inputs". It must be
really a simple thing, but I canīt figure it out....</FONT></DIV>
<DIV><FONT face=Arial size=2> I'm using VTK v4.2 and ITK v
2.4.1</FONT></DIV>
<DIV><FONT face=Arial size=2> Here's the code:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV><FONT color=#0000ff size=2>
<DIV><FONT face=Arial color=#000000>#include</FONT></FONT><FONT face=Arial
size=2> "vtkVolume16Reader.h"</FONT></DIV>
<DIV><FONT size=2><FONT face=Arial color=#0000ff>#include</FONT><FONT
face=Arial> "vtkImageExport.h"</FONT></FONT></DIV><FONT color=#0000ff size=2>
<DIV><FONT face=Arial color=#000000>#include</FONT></FONT><FONT size=2><FONT
face=Arial> <itkVTKImageImport.h></FONT></DIV></FONT><FONT color=#0000ff
size=2>
<DIV><FONT face=Arial color=#000000>#include</FONT></FONT><FONT size=2><FONT
face=Arial> <itkVTKImageExport.h></FONT></DIV></FONT><FONT color=#0000ff
size=2>
<DIV><FONT face=Arial color=#000000>#include</FONT></FONT><FONT size=2><FONT
face=Arial> "itkPNGImageIO.h"</FONT></DIV></FONT><FONT color=#0000ff size=2>
<DIV><FONT face=Arial color=#000000>#include</FONT></FONT><FONT size=2><FONT
face=Arial> "itkImageFileWriter.h"</FONT></FONT></DIV>
<DIV><FONT size=2><FONT face=Arial></FONT></FONT> </DIV>
<DIV><FONT color=#0000ff size=2><FONT face=Arial
color=#000000>typedef</FONT></FONT><FONT face=Arial><FONT size=2>
itk::Image<</FONT><FONT size=2>unsigned</FONT><FONT size=2> </FONT><FONT
size=2>short</FONT></FONT><FONT size=2><FONT face=Arial>,2>
imageType;</FONT></DIV></FONT><FONT color=#0000ff size=2>
<DIV><FONT face=Arial color=#000000>typedef</FONT></FONT><FONT size=2><FONT
face=Arial> itk::VTKImageImport<imageType>
importerType;</FONT></DIV></FONT><FONT color=#0000ff size=2>
<DIV><FONT face=Arial color=#000000>typedef</FONT></FONT><FONT size=2><FONT
face=Arial> itk::ImageFileWriter<imageType>
writerType;</FONT></DIV></FONT><FONT color=#0000ff size=2>
<DIV><FONT face=Arial color=#000000></FONT> </DIV>
<DIV><FONT face=Arial color=#000000></FONT> </DIV>
<DIV><FONT face=Arial color=#000000>void</FONT></FONT><FONT size=2><FONT
face=Arial> ConnectVTKToITK(vtkImageExport* in, importerType* out)</FONT></DIV>
<DIV><FONT face=Arial>{</FONT></DIV>
<DIV><FONT
face=Arial>out->SetUpdateInformationCallback(in->GetUpdateInformationCallback());</FONT></DIV>
<DIV><FONT
face=Arial>out->SetPipelineModifiedCallback(in->GetPipelineModifiedCallback());</FONT></DIV>
<DIV><FONT
face=Arial>out->SetWholeExtentCallback(in->GetWholeExtentCallback());</FONT></DIV>
<DIV><FONT
face=Arial>out->SetSpacingCallback(in->GetSpacingCallback());</FONT></DIV>
<DIV><FONT
face=Arial>out->SetOriginCallback(in->GetOriginCallback());</FONT></DIV>
<DIV><FONT
face=Arial>out->SetScalarTypeCallback(in->GetScalarTypeCallback());</FONT></DIV>
<DIV><FONT
face=Arial>out->SetNumberOfComponentsCallback(in->GetNumberOfComponentsCallback());</FONT></DIV>
<DIV><FONT
face=Arial>out->SetPropagateUpdateExtentCallback(in->GetPropagateUpdateExtentCallback());</FONT></DIV>
<DIV><FONT
face=Arial>out->SetUpdateDataCallback(in->GetUpdateDataCallback());</FONT></DIV>
<DIV><FONT
face=Arial>out->SetDataExtentCallback(in->GetDataExtentCallback());</FONT></DIV>
<DIV><FONT
face=Arial>out->SetBufferPointerCallback(in->GetBufferPointerCallback());</FONT></DIV>
<DIV><FONT
face=Arial>out->SetCallbackUserData(in->GetCallbackUserData());</FONT></DIV>
<DIV><FONT face=Arial>}</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial></FONT> </DIV></FONT><FONT color=#0000ff size=2>
<DIV><FONT face=Arial color=#000000>int</FONT></FONT><FONT size=2><FONT
face=Arial> main(){</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>vtkVolume16Reader* reader =
vtkVolume16Reader::New();</FONT></DIV>
<DIV><FONT face=Arial>reader->SetFilePrefix("d:\\quarter");</FONT></DIV>
<DIV><FONT face=Arial>reader->SetImageRange(50,50);</FONT></DIV>
<DIV><FONT face=Arial>reader->SetDataDimensions(64,64);</FONT></DIV>
<DIV><FONT face=Arial>reader->SetDataSpacing(3.2,3.2,1);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>vtkImageExport* exporter =
vtkImageExport::New();</FONT></DIV>
<DIV><FONT
face=Arial>exporter->SetInput(reader->GetOutput());</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>importerType::Pointer importer =
importerType::New();</FONT></DIV>
<DIV><FONT face=Arial>ConnectVTKToITK(exporter,importer);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV></FONT><FONT face=Arial color=#0000ff size=2>typedef</FONT><FONT
size=2><FONT face=Arial> itk::PNGImageIO ioType;</FONT></DIV>
<DIV><FONT face=Arial>ioType::Pointer PNGio = ioType::New();</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>writerType::Pointer writer =
writerType::New();</FONT></DIV>
<DIV><FONT face=Arial>writer->SetImageIO(PNGio);</FONT></DIV>
<DIV><FONT
face=Arial>writer->SetInput(importer->GetOutput());</FONT></DIV>
<DIV><FONT
face=Arial>writer->SetFileName("d:\\quarterteste.png");</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>importer->Print(std::cout);</FONT></DIV>
<DIV><FONT face=Arial>exporter->Print(std::cout);</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial>system("pause");</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff></FONT></FONT><FONT face=Arial color=#0000ff
size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2>try</FONT><FONT size=2><FONT
face=Arial>{</FONT></DIV>
<DIV><FONT face=Arial>writer->Update();</FONT></DIV>
<DIV><FONT face=Arial>}</FONT></DIV>
<DIV><FONT face=Arial color=#0000ff></FONT></FONT><FONT face=Arial color=#0000ff
size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#0000ff size=2>catch</FONT><FONT size=2><FONT
face=Arial>( itk::ExceptionObject & err ){</FONT></DIV>
<DIV><FONT face=Arial>std::cerr<<"Excecao capturada!";</FONT></DIV>
<DIV><FONT face=Arial>std::cout << err << std::endl;</FONT></DIV>
<DIV><FONT face=Arial>system("pause");</FONT></DIV>
<DIV><FONT face=Arial>}</FONT></DIV>
<DIV><FONT face=Arial>}</FONT></DIV>
<DIV><FONT face=Arial></FONT> </DIV>
<DIV><FONT face=Arial> Thanks in
advance!</FONT></DIV></FONT></BODY></HTML>