<div dir="ltr">Sorry for the incomplete message.<br><br>Hi Mark,<br><br>I wonder whether you can use vtkImageToImageFilter to hold the image data from the exporter.<br><br>Any way I use the <span style="color:#008000">itkVTKImageToImageFilter to do the conversion and it works well for me.<br>
<br>Here is the snippet<br><br><br></span><span style="color:#c0c0c0"> </span><font size="4"><span style="color:rgb(128, 128, 0)">typedef</span><span style="color:rgb(192, 192, 192)"> </span>itk<span style="color:rgb(0, 0, 0)">::</span>Image<span style="color:rgb(0, 0, 0)"><</span><span style="color:rgb(128, 128, 0)">unsigned</span><span style="color:rgb(192, 192, 192)"> </span><span style="color:rgb(128, 128, 0)">int</span><span style="color:rgb(0, 0, 0)">,</span><span style="color:rgb(0, 0, 128)">3</span><span style="color:rgb(0, 0, 0)">></span><span style="color:rgb(192, 192, 192)"> </span>ImageType<span style="color:rgb(0, 0, 0)">;</span>
</font><pre style="margin:0px;text-indent:0px"><font size="4"><span style="color:rgb(192, 192, 192)"> </span><span style="color:rgb(128, 128, 0)">typedef</span><span style="color:rgb(192, 192, 192)"> </span>itk<span style="color:rgb(0, 0, 0)">::</span>VTKImageToImageFilter<span style="color:rgb(0, 0, 0)"><</span>ImageType<span style="color:rgb(0, 0, 0)">></span>VTKImageToImageType<span style="color:rgb(0, 0, 0)">;</span></font></pre>
<font size="4">
</font><pre style="margin:0px;text-indent:0px"><font size="4"><span style="color:rgb(192, 192, 192)"> </span>VTKImageToImageType<span style="color:rgb(0, 0, 0)">::</span>Pointer<span style="color:rgb(192, 192, 192)"> </span>converter<span style="color:rgb(0, 0, 0)">=</span>VTKImageToImageType<span style="color:rgb(0, 0, 0)">::</span>New<span style="color:rgb(0, 0, 0)">();</span></font></pre>
<font size="4">
</font><pre style="margin:0px;text-indent:0px"><font size="4"><span style="color:rgb(192, 192, 192)"> </span>converter<span style="color:rgb(0, 0, 0)">-></span>SetInput<span style="color:rgb(0, 0, 0)">(imgData</span><span style="color:rgb(0, 0, 0)">);</span></font></pre>
<font size="4">
</font><pre style="margin:0px;text-indent:0px"><font size="4"><span style="color:rgb(192, 192, 192)"> </span>converter<span style="color:rgb(0, 0, 0)">-></span>Update<span style="color:rgb(0, 0, 0)">();<br><br>Now you could get the itk image as converter->GetOutput(). I have attached the src and headers for you.<br>
<br>Jothy<br><br><br></span></font></pre><br><br><div class="gmail_quote">On Tue, Sep 20, 2011 at 10:19 AM, Jothy <span dir="ltr"><<a href="mailto:jothybasu@gmail.com">jothybasu@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div dir="ltr">Hi Mark,<br><br>I wonder whether you can use vtkImageToImageFilter to hold the image data from the exporter.<br><br>Any way I use the <span style="color:#008000">itkVTKImageToImageFilter to do the conversion and it works well for me.<br>
<br>Here is the snippet<br><br><br></span><span style="color:#c0c0c0"> </span><font size="4"><span style="color:rgb(128, 128, 0)">typedef</span><span style="color:rgb(192, 192, 192)"> </span>itk<span style="color:rgb(0, 0, 0)">::</span>Image<span style="color:rgb(0, 0, 0)"><</span><span style="color:rgb(128, 128, 0)">unsigned</span><span style="color:rgb(192, 192, 192)"> </span><span style="color:rgb(128, 128, 0)">int</span><span style="color:rgb(0, 0, 0)">,</span><span style="color:rgb(0, 0, 128)">3</span><span style="color:rgb(0, 0, 0)">></span><span style="color:rgb(192, 192, 192)"> </span>ImageType<span style="color:rgb(0, 0, 0)">;</span>
</font><pre style="margin:0px;text-indent:0px"><font size="4"><span style="color:rgb(192, 192, 192)"> </span><span style="color:rgb(128, 128, 0)">typedef</span><span style="color:rgb(192, 192, 192)"> </span>itk<span style="color:rgb(0, 0, 0)">::</span>VTKImageToImageFilter<span style="color:rgb(0, 0, 0)"><</span>ImageType<span style="color:rgb(0, 0, 0)">></span>VTKImageToImageType<span style="color:rgb(0, 0, 0)">;</span></font></pre>
<font size="4">
</font><pre style="margin:0px;text-indent:0px"><font size="4"><span style="color:rgb(192, 192, 192)"> </span>VTKImageToImageType<span style="color:rgb(0, 0, 0)">::</span>Pointer<span style="color:rgb(192, 192, 192)"> </span>converter<span style="color:rgb(0, 0, 0)">=</span>VTKImageToImageType<span style="color:rgb(0, 0, 0)">::</span>New<span style="color:rgb(0, 0, 0)">();</span></font></pre>
<font size="4">
</font><pre style="margin:0px;text-indent:0px"><font size="4"><span style="color:rgb(192, 192, 192)"> </span>converter<span style="color:rgb(0, 0, 0)">-></span>SetInput<span style="color:rgb(0, 0, 0)">(</span>stencil2<span style="color:rgb(0, 0, 0)">-></span>GetOutput<span style="color:rgb(0, 0, 0)">());</span></font></pre>
<font size="4">
</font><pre style="margin:0px;text-indent:0px"><font size="4"><span style="color:rgb(192, 192, 192)"> </span>converter<span style="color:rgb(0, 0, 0)">-></span>Update<span style="color:rgb(0, 0, 0)">();</span></font></pre>
<div><div></div><div class="h5">
<br><br><br><div class="gmail_quote">On Tue, Sep 20, 2011 at 5:59 AM, Mark Roden <span dir="ltr"><<a href="mailto:mmroden@gmail.com" target="_blank">mmroden@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hi all,<br>
<br>
I've looked on google and the various newsgroups and have not found<br>
the answer to what I thought was a pretty straightforward question.<br>
<br>
I have a vtkImageData object that has been obtained... somehow. I do<br>
not have the pipeline at this point, just the output. The user could<br>
have done any number of things to have arrived at this point, and so I<br>
store a vtkImageData that has been DeepCopied off of the end of<br>
whatever pipeline was employed.<br>
<br>
I then want to save that image in the Analyze format. A coworker made<br>
his own reader/writer using the information that Mayo put out, but the<br>
resulting files don't appear to be oriented correctly. I want to<br>
verify if his version is producing a bug, and I wanted to use the itk<br>
version of the writing plugin to do the work.<br>
<br>
Here's what I have:<br>
<br>
#ifdef ITK_IMG_WRITER<br>
#include "vtkImageExport.h"<br>
#include <itkVTKImageImport.h><br>
#include "itkImageFileWriter.h"<br>
#include "itkAnalyzeImageIO.h"<br>
#include "itkImage.h"<br>
#include "itkOrientedImage.h"<br>
#endif<br>
<br>
<br>
void saveAnalyzeImage(vtkImageData * const image, const QString &file) {<br>
<br>
#ifdef ITK_IMG_WRITER<br>
//this code is done using ITK, and so requires that ITK be included<br>
typedef itk::OrientedImage< signed short, 3 > CTImage;<br>
typedef itk::ImageFileWriter< CTImage> CTWriter;<br>
typedef itk::VTKImageImport<CTImage> VTKImageImportType;<br>
<br>
CTWriter::Pointer theWriter = CTWriter::New();<br>
<br>
theWriter->SetFileName(file.toStdString().c_str());<br>
<br>
vtkImageExport* theExporter = vtkImageExport::New();<br>
theExporter->SetInput(image);<br>
<br>
VTKImageImportType::Pointer vtkImageToImageFilter =<br>
VTKImageImportType::New();<br>
theExporter->SetOutput(vtkImageToImageFilter);<br>
vtkImageToImageFilter->Update();<br>
<br>
theWriter->SetInput(vtkImageToImageFilter->GetOutput());<br>
<br>
itk::AnalyzeImageIO::Pointer analyzeIO = itk::AnalyzeImageIO::New();<br>
theWriter->SetImageIO(analyzeIO);<br>
<br>
try {<br>
theWriter->Update();<br>
} catch(itk::ExceptionObject ex){<br>
return; //do something else here for error handling<br>
}<br>
theWriter->Delete();<br>
vtkImageToImageFilter->Delete();<br>
analyzeIO->Delete();<br>
return;<br>
<br>
#else<br>
//do the other code instead<br>
#endif<br>
}<br>
<br>
This code is not compiling, because<br>
theExporter->SetOutput(vtkImageToImageFilter) doesn't work. I've also<br>
tried just using the VTKImageImportType object directly, but that does<br>
not have a SetInput method. As could be guessed from the code, I also<br>
tried vtkImageToImageFilter, but that appears to be a deprecated<br>
leftover from 2004 or so. Unless there's some include file I'm not<br>
finding?<br>
<br>
All I really want is for vtk to read and write analyze files. Barring<br>
that, I want to be able to seamlessly convert from a vtkImageData<br>
object to an itk::Image object so I can use itk's analyze export and<br>
importing functions. How can I fix that code to make it work?<br>
<br>
Thanks,<br>
Mark<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 <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br><br clear="all"><br></div></div><font color="#888888">-- <br><div dir="ltr">Jothybasu K Selvaraj<br>PhD Student<br>University of Liverpool<br>Liverpool,UK<br></div><br>
</font></div>
</blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">Jothybasu K Selvaraj<br>PhD Student<br>University of Liverpool<br>Liverpool,UK<br></div><br>
</div>