Thanks Luis, here is the code:<br><br>#include "itkOrientedImage.h"<br>#include "itkGDCMImageIO.h"<br>#include "itkGDCMSeriesFileNames.h"<br>#include "itkImageSeriesReader.h"<br>#include "itkImageFileWriter.h"<br>
<br>#include "itkImageToVTKImageFilter.h"<br><br>#include "vtkRenderer.h"<br>#include "vtkRenderWindow.h"<br>#include "vtkRenderWindowInteractor.h"<br>#include "vtkPolyDataMapper.h"<br>
#include "vtkActor.h"<br>#include "vtkCamera.h"<br>#include "vtkPolyDataNormals.h"<br>#include "vtkStructuredPointsReader.h"<br>#include "vtkMarchingCubes.h"<br>#include "vtkProperty.h"<br>
#include "vtkCleanPolyData.h"<br><br><br><br>int main( int argc, char* argv[] )<br>{<br><br>long int size[3];<br>double IntesityLevel=atof(argv[2]);<br><br> typedef signed short PixelType;<br> const unsigned int Dimension = 3;<br>
<br> typedef itk::OrientedImage< PixelType, Dimension > ImageType;<br><br> typedef itk::ImageSeriesReader< ImageType > ReaderType;<br> ReaderType::Pointer reader = ReaderType::New();<br><br> typedef itk::GDCMImageIO ImageIOType;<br>
ImageIOType::Pointer dicomIO = ImageIOType::New();<br> <br> reader->SetImageIO( dicomIO );<br><br> typedef itk::GDCMSeriesFileNames NamesGeneratorType;<br> NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();<br>
<br> nameGenerator->SetUseSeriesDetails( true );<br> nameGenerator->AddSeriesRestriction("0008|0021" );<br><br> nameGenerator->SetDirectory( argv[1] );<br><br><br> <br> std::cout << std::endl << "The directory: " << std::endl;<br>
std::cout << std::endl << argv[1] << std::endl << std::endl;<br> std::cout << "Contains the following DICOM Series: ";<br> std::cout << std::endl << std::endl;<br>
<br> typedef std::vector< std::string > SeriesIdContainer;<br> <br> const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();<br> <br> SeriesIdContainer::const_iterator seriesItr = seriesUID.begin();<br>
SeriesIdContainer::const_iterator seriesEnd = seriesUID.end();<br> while( seriesItr != seriesEnd )<br> {<br> std::cout << seriesItr->c_str() << std::endl;<br> seriesItr++;<br> }<br>
<br> std::string seriesIdentifier;<br><br> <br> seriesIdentifier = seriesUID.begin()->c_str();<br> <br><br> std::cout << std::endl << std::endl;<br> std::cout << "Now reading series: " << std::endl << std::endl;<br>
std::cout << seriesIdentifier << std::endl;<br> std::cout << std::endl << std::endl;<br><br><br> typedef std::vector< std::string > FileNamesContainer;<br> FileNamesContainer fileNames;<br>
<br> fileNames = nameGenerator->GetFileNames( seriesIdentifier );<br><br> reader->SetFileNames( fileNames );<br><br> try<br> {<br> reader->Update();<br> }<br> catch (itk::ExceptionObject &ex)<br>
{<br> std::cout << ex << std::endl;<br> return EXIT_FAILURE;<br> }<br><br>size[0] = reader->GetOutput()->GetRequestedRegion().GetSize()[0] ;<br>size[1] = reader->GetOutput()->GetRequestedRegion().GetSize()[1] ;<br>
size[2] = reader->GetOutput()->GetRequestedRegion().GetSize()[2] ;<br>std::cout << "A térfogat méretei:" << std::endl;<br>std::cout << "x:" << size[0] << std::endl;<br>
std::cout << "y:" << size[1] << std::endl;<br>std::cout << "z:" << size[2] << std::endl;<br><br>///////////////////////////////////////// ITK ///////////////////////////////////////////////////////////////////<br>
<br> typedef itk::ImageToVTKImageFilter< ImageType> ConnectorType;<br> ConnectorType::Pointer connector = ConnectorType::New();<br> connector->SetInput( reader->GetOutput() );<br><br>///////////////////////////////////////// VTK ////////////////////////////////////////////////////////////////////<br>
<br> vtkRenderer *renderer = vtkRenderer::New();<br> vtkRenderWindow *window = vtkRenderWindow::New();<br> window->AddRenderer(renderer);<br> vtkRenderWindowInteractor *interactor = vtkRenderWindowInteractor::New();<br>
interactor->SetRenderWindow(window);<br><br> <br> <br> vtkStructuredPointsReader *vreader = vtkStructuredPointsReader::New(); <br> vreader->SetInputConnection( connector->GetOutput() );<br> //reader->SetFileName(argv[1]);<br>
<br> vtkMarchingCubes *iso = vtkMarchingCubes::New();<br> iso->SetInputConnection(vreader->GetOutputPort());<br> iso->SetValue( 0, IntesityLevel);<br><br> vtkCleanPolyData *clean = vtkCleanPolyData::New();<br>
clean->SetInputConnection(iso->GetOutputPort());<br><br> vtkPolyDataNormals *normal = vtkPolyDataNormals::New();<br> normal->SetInputConnection(clean->GetOutputPort());<br> normal->SetFeatureAngle(60.0);<br>
<br> vtkPolyDataMapper *mapper = vtkPolyDataMapper::New();<br> mapper->SetInputConnection(normal->GetOutputPort());<br> mapper->ScalarVisibilityOff();<br><br> vtkActor *isoactor = vtkActor::New();<br>
isoactor->SetMapper(mapper);<br> isoactor->GetProperty()->SetColor(1,1,0);<br> <br> vtkCamera *camera = vtkCamera::New();<br> camera->SetViewUp (0, 0, 1);<br> camera->SetPosition (0, -1, 0);<br>
/* camera->SetFocalPoint (0, 0, 0);*/<br> camera->ComputeViewPlaneNormal();<br><br> <br> renderer->AddActor(isoactor);<br> renderer->SetActiveCamera(camera);<br> renderer->ResetCamera ();<br>
camera->Dolly(1);<br><br> <br> renderer->SetBackground(1,1,1);<br> window->SetSize(640, 480);<br><br> <br> renderer->ResetCameraClippingRange ();<br><br> interactor->Initialize();<br> window->SetWindowName( "Koponya" ); //azert itt mert bugos<br>
interactor->Start(); <br><br> std::cout << "Kész" << std::endl;<br><br> <br> reader->Delete();<br> dicomIO->Delete();<br> nameGenerator->Delete();<br> connector->Delete();<br>
renderer->Delete();<br> window->Delete();<br> interactor->Delete();<br> vreader->Delete();<br> iso->Delete();<br> clean->Delete();<br> normal->Delete();<br> mapper->Delete();<br>
isoactor->Delete();<br> camera->Delete();<br><br><br> return EXIT_SUCCESS;<br><br>}<br><br><br><div class="gmail_quote">2009/3/22 Luis Ibanez <span dir="ltr"><<a href="mailto:luis.ibanez@kitware.com">luis.ibanez@kitware.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi Arepi,<br>
<br>
Please post your code...<br>
<br>
It doesn't makes much sense to connect the output of an importer<br>
as the input of a reader. (maybe you meant to say a "writer" ?).<br>
<br>
Source code will be better that a verbal description of the source code :-)<br>
<br>
Thanks<br>
<br>
Luis<br>
<br>
<br>
------------------------------------------<br>
On Sun, Mar 22, 2009 at 11:07 AM, Arepi <<a href="mailto:szamosi.arpad@gmail.com">szamosi.arpad@gmail.com</a>> wrote:<br>
><br>
> Hi,<br>
><br>
> I tried connect itk to vtk whit itkImageToVTKImageFilter. The first part is<br>
> itk and read a DICOM series(see<br>
> Examples/IO/DicomSeriesReadImageWrite2.cxx.), but I would the reader input<br>
> connect to vtk, instead write to a .vtk file. The second part is vtk and I<br>
> tried connect the itkImageToVTKImageFilter output to en<br>
> vtkStructuredPointsReader(and than MarchingCubes, DataNormal etc) but came<br>
> back whit following error:<br>
><br>
> error C2664: 'void vtkAlgorithm::SetInputConnection(vtkAlgorithmOutput *)'<br>
> : cannot convert parameter 1 from 'vtkImageData *' to 'vtkAlgorithmOutput *'<br>
> Types pointed to are unrelated; conversion requires<br>
> reinterpret_cast, C-style cast or function-style cast<br>
><br>
> I choossed a wrong reader or what should I do to works it fine?<br>
><br>
> Thanks!<br>
><br>
> Arepi<br>
> --<br>
> View this message in context: <a href="http://www.nabble.com/itkImageToVTKImageFilter-tp22646859p22646859.html" target="_blank">http://www.nabble.com/itkImageToVTKImageFilter-tp22646859p22646859.html</a><br>
> Sent from the ITK - Users mailing list archive at Nabble.com.<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>
> Please keep messages on-topic and check the ITK FAQ at: <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>
><br>
</blockquote></div><br>