<div dir="ltr"><div dir="ltr"><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Hi Marco,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">that is more of a VTK question than ITK one, best directed at <a href="mailto:vtkusers@vtk.org">vtkusers@vtk.org</a>. Also, ITK has migrated to a new <a href="https://discourse.itk.org/">forum</a>. Please post further ITK-related questions there instead of this mailing list.</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small"><br></div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Regards,</div><div class="gmail_default" style="font-family:verdana,sans-serif;font-size:small">Dženan</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 15, 2019 at 12:54 PM Marco Festugato <<a href="mailto:marco.festugato@outlook.it">marco.festugato@outlook.it</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi Dzenan and thank u for your answer <span id="gmail-m_8268737350121040255🙂" title=":lieve_sorriso:">🙂</span> I've tried to do as u suggested, but i receive an error telling me that my mapper doesnt accept ''scalar cells''...maybe this connector doesnt work with my mapper? i've tried
to simply add the 'connector' to my pipeline:<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
reader -> connector -> mapper -> volume -> renderer -> window</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Here's my code if u want to check it (it still needs a bit of cleaning)...i would appreciate it a lot!! I need this to work for my project :'(
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span> // VTK includes<br>
</span>
<div>#include "vtkDICOMImageReader.h"<br>
</div>
<div>#include "vtkImageData.h"<br>
</div>
<div>#include "vtkRenderer.h"<br>
</div>
<div>#include "vtkRenderWindow.h"<br>
</div>
<div>#include "vtkRenderWindowInteractor.h"<br>
</div>
<div>#include "vtkVolume.h"<br>
</div>
<div>#include <vtkInteractorStyleTrackballCamera.h><br>
</div>
<div>#include <vtkVolumeProperty.h><br>
</div>
<div>#include <vtkSmartPointer.h><br>
</div>
<div>#include <vtkPiecewiseFunction.h><br>
</div>
<div>#include <vtkVolumeRayCastCompositeFunction.h><br>
</div>
<div>#include <vtkFixedPointVolumeRayCastMapper.h><br>
</div>
<div>#include <itkImage.h><br>
</div>
<div>#include <itkImageFileReader.h><br>
</div>
<div>#include <itkImageToVTKImageFilter.h><br>
</div>
<div>#include "vtkVersion.h"<br>
</div>
<div>#include "vtkImageViewer.h"<br>
</div>
<div>#include "vtkImageMapper3D.h"<br>
</div>
<div>#include "vtkRenderWindowInteractor.h"<br>
</div>
<div>#include "vtkSmartPointer.h"<br>
</div>
<div>#include "vtkImageActor.h"<br>
</div>
<div>#include "vtkInteractorStyleImage.h"<br>
</div>
<div>#include "vtkRenderer.h"<br>
</div>
<div>#include "itkImage.h"<br>
</div>
<div>#include "itkGDCMImageIO.h"<br>
</div>
<div>#include "itkGDCMSeriesFileNames.h"<br>
</div>
<div>#include "itkImageSeriesReader.h"<br>
</div>
<div>#include "itkImageFileWriter.h"<br>
</div>
<div><br>
</div>
<div> int main(int argc, char *argv[])<br>
</div>
<div>{<br>
</div>
<div> // Verify the number of parameters in the command line<br>
</div>
<div> if( argc < 2)<br>
</div>
<div> {<br>
</div>
<div> std::cerr << "Usage: " << std::endl;<br>
</div>
<div> std::cerr << argv[0] << " DICOMimagesDirectory " << std::endl;<br>
</div>
<div> return EXIT_FAILURE;<br>
</div>
<div> }<br>
</div>
<div> // Software Guide : BeginCodeSnippet<br>
</div>
<div> typedef signed short PixelType;<br>
</div>
<div> const unsigned int Dimension = 3;<br>
</div>
<div> typedef itk::Image< PixelType, Dimension > ImageType;<br>
</div>
<div> typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;<br>
</div>
<div><br>
</div>
<div> ConnectorType::Pointer connector = ConnectorType::New();<br>
</div>
<div> <br>
</div>
<div>// We use the image type for instantiating the type of the series reader and<br>
</div>
<div>// for constructing one object of its type.<br>
</div>
<div><br>
</div>
<div> typedef itk::ImageSeriesReader< ImageType > ReaderType;<br>
</div>
<div> ReaderType::Pointer reader = ReaderType::New();<br>
</div>
<div><br>
</div>
<div>// A GDCMImageIO object is created and connected to the reader. This object is<br>
</div>
<div>// the one that is aware of the internal intricacies of the DICOM format.<br>
</div>
<div>//<br>
</div>
<div><br>
</div>
<div> typedef itk::GDCMImageIO ImageIOType;<br>
</div>
<div> ImageIOType::Pointer dicomIO = ImageIOType::New();<br>
</div>
<div><br>
</div>
<div> reader->SetImageIO( dicomIO );<br>
</div>
<div><br>
</div>
<div> using NamesGeneratorType = itk::GDCMSeriesFileNames;<br>
</div>
<div> NamesGeneratorType::Pointer nameGenerator = NamesGeneratorType::New();<br>
</div>
<div><br>
</div>
<div> nameGenerator->SetUseSeriesDetails( true ); <br>
</div>
<div> nameGenerator->SetDirectory( argv[1] ); <br>
</div>
<div><br>
</div>
<div> try<br>
</div>
<div> {<br>
</div>
<div> std::cout << std::endl << "The directory: " << std::endl;<br>
</div>
<div> std::cout << std::endl << argv[1] << std::endl << std::endl;<br>
</div>
<div> std::cout << "Contains the following DICOM Series: ";<br>
</div>
<div> std::cout << std::endl << std::endl;<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>// Software Guide : BeginLatex<br>
</div>
<div>//<br>
</div>
<div>// The GDCMSeriesFileNames object first identifies the list of DICOM series<br>
</div>
<div>// present in the given directory. We receive that list in a reference<br>
</div>
<div>// to a container of strings and then we can do things like print out all<br>
</div>
<div>// the series identifiers that the generator had found. Since the process of<br>
</div>
<div>// finding the series identifiers can potentially throw exceptions, it is<br>
</div>
<div>// wise to put this code inside a \code{try/catch} block.<br>
</div>
<div>//<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div> typedef std::vector< std::string > SeriesIdContainer;<br>
</div>
<div><br>
</div>
<div> const SeriesIdContainer & seriesUID = nameGenerator->GetSeriesUIDs();<br>
</div>
<div><br>
</div>
<div>// Given that it is common to find multiple DICOM series in the same directory,<br>
</div>
<div>// we must tell the GDCM classes what specific series we want to read. In<br>
</div>
<div>// this example we do this by checking first if the user has provided a series<br>
</div>
<div>// identifier in the command line arguments. If no series identifier has been<br>
</div>
<div>// passed, then we simply use the first series found during the exploration of<br>
</div>
<div>// the directory.<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div> std::string seriesIdentifier;<br>
</div>
<div><br>
</div>
<div> seriesIdentifier = seriesUID.begin()->c_str();<br>
</div>
<div><br>
</div>
<div> std::cout << std::endl << std::endl;<br>
</div>
<div> std::cout << "Now reading series: " << std::endl << std::endl;<br>
</div>
<div> std::cout << seriesIdentifier << std::endl;<br>
</div>
<div> std::cout << std::endl << std::endl;<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>// We pass the series identifier to the name generator and ask for all the<br>
</div>
<div>// filenames associated to that series. This list is returned in a container of<br>
</div>
<div>// strings by the \code{GetFileNames()} method.<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div> typedef std::vector< std::string > FileNamesContainer;<br>
</div>
<div> FileNamesContainer fileNames;<br>
</div>
<div><br>
</div>
<div> fileNames = nameGenerator->GetFileNames( seriesIdentifier );<br>
</div>
<div><br>
</div>
<div>//<br>
</div>
<div>// The list of filenames can now be passed to the \doxygen{ImageSeriesReader}<br>
</div>
<div>// using the \code{SetFileNames()} method.<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div> reader->SetFileNames( fileNames );<br>
</div>
<div><br>
</div>
<div>// Finally we can trigger the reading process by invoking the \code{Update()}<br>
</div>
<div>// method in the reader. This call as usual is placed inside a \code{try/catch}<br>
</div>
<div>// block.<br>
</div>
<div><br>
</div>
<div> try<br>
</div>
<div> {<br>
</div>
<div> reader->Update();<br>
</div>
<div> }<br>
</div>
<div> catch (itk::ExceptionObject &ex)<br>
</div>
<div> {<br>
</div>
<div> std::cout << ex << std::endl;<br>
</div>
<div> return EXIT_FAILURE;<br>
</div>
<div> }<br>
</div>
<div>}<br>
</div>
<div> catch (itk::ExceptionObject &ex)<br>
</div>
<div> {<br>
</div>
<div> std::cout << ex << std::endl;<br>
</div>
<div> return EXIT_FAILURE;<br>
</div>
<div> }<br>
</div>
<div><br>
</div>
<div> // Visualization pipeline<br>
</div>
<div><br>
</div>
<div> // Create the renderer, render window and interactor<br>
</div>
<div> vtkRenderer *renderer = vtkRenderer::New();<br>
</div>
<div> vtkRenderWindow *renWin = vtkRenderWindow::New();<br>
</div>
<div> renWin->AddRenderer(renderer);<br>
</div>
<div> <br>
</div>
<div> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();<br>
</div>
<div> iren->SetRenderWindow(renWin);<br>
</div>
<div> <br>
</div>
<div> // Read the data<br>
</div>
<div> vtkImageData *input = nullptr;<br>
</div>
<div><br>
</div>
<div>/* vtkDICOMImageReader *reader = vtkDICOMImageReader::New();<br>
</div>
<div>// vtkTIFFReader *reader = vtkTIFFReader::New();<br>
</div>
<div> reader->SetFileName(argv[1]); */<br>
</div>
<div> // reader->Update(); // read data<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div> connector->SetInput(reader->GetOutput());<br>
</div>
<div> <br>
</div>
<div> // Create our volume and mapper<br>
</div>
<div> vtkVolume *volume = vtkVolume::New();<br>
</div>
<div> vtkFixedPointVolumeRayCastMapper *mapper = vtkFixedPointVolumeRayCastMapper::New();<br>
</div>
<div>// vtkVolumeRayCastCompositeFunction *compositeFunction = vtkVolumeRayCastCompositeFunction::New();<br>
</div>
<div>vtkInteractorStyleTrackballCamera *styleCamera = vtkInteractorStyleTrackballCamera::New();<br>
</div>
<div><br>
</div>
<div> // connect up the volume to the property and the mapper<br>
</div>
<div> mapper -> SetInputData( connector -> GetOutput() );<br>
</div>
<div>mapper -> SetSampleDistance( 0.1 );<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkVolumeProperty> volumeProperty = vtkSmartPointer<vtkVolumeProperty>::New();<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>volumeProperty->SetInterpolationTypeToLinear(); // better image quality but computation's longer<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>vtkSmartPointer<vtkPiecewiseFunction> scalarOpacity = vtkSmartPointer<vtkPiecewiseFunction>::New();<br>
</div>
<div>vtkSmartPointer<vtkPiecewiseFunction> gradientOpacity = vtkSmartPointer<vtkPiecewiseFunction>::New();<br>
</div>
<div><br>
</div>
<div> scalarOpacity->AddPoint(0, 0.00);<br>
</div>
<div> scalarOpacity->AddPoint(500, 0.15);<br>
</div>
<div> scalarOpacity->AddPoint(1000, 0.15);<br>
</div>
<div> scalarOpacity->AddPoint(1150, 0.85);<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div> gradientOpacity->AddPoint(0, 0.0);<br>
</div>
<div> gradientOpacity->AddPoint(90, 0.5);<br>
</div>
<div> gradientOpacity->AddPoint(100, 1.0);<br>
</div>
<br>
<div><br>
</div>
<div>//set the transfer functions to the property<br>
</div>
<div>volumeProperty->SetScalarOpacity(scalarOpacity);<br>
</div>
<div>volumeProperty->SetGradientOpacity(gradientOpacity);<br>
</div>
<div><br>
</div>
<div>//set the property to the volume<br>
</div>
<div><br>
</div>
<div>volume->SetProperty(volumeProperty);<br>
</div>
<div><br>
</div>
<div>volume->SetMapper( mapper );<br>
</div>
<div> iren -> SetInteractorStyle(styleCamera);<br>
</div>
<div> // Set the default window size<br>
</div>
<div> renWin->SetSize(600,600);<br>
</div>
<div> <br>
</div>
<div> // Add the volume to the scene<br>
</div>
<div> renderer->AddVolume( volume );<br>
</div>
<div> <br>
</div>
<div> // interact with data<br>
</div>
<div> renWin->Render();<br>
</div>
<div> iren -> Start();<br>
</div>
<div><br>
</div>
<div> <br>
</div>
<div> return EXIT_SUCCESS;<br>
</div>
<div> }<br>
</div>
<div><br>
</div>
<span></span><br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="gmail-m_8268737350121040255signature">
<div id="gmail-m_8268737350121040255divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
Inviato da <a href="http://aka.ms/weboutlook" target="_blank">Outlook</a></div>
</div>
<div id="gmail-m_8268737350121040255appendonsend"></div>
<hr style="display:inline-block;width:98%">
<div id="gmail-m_8268737350121040255divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>Da:</b> Dženan Zukić <<a href="mailto:dzenanz@gmail.com" target="_blank">dzenanz@gmail.com</a>><br>
<b>Inviato:</b> venerdì 15 marzo 2019 17:19<br>
<b>A:</b> Marco Festugato<br>
<b>Cc:</b> <a href="mailto:insight-users@itk.org" target="_blank">insight-users@itk.org</a><br>
<b>Oggetto:</b> Re: [ITK-users] Reading DICOM series and visualize the volume with VTK</font>
<div> </div>
</div>
<div>
<div dir="ltr">
<div class="gmail-m_8268737350121040255x_gmail_default" style="font-family:verdana,sans-serif;font-size:small">
Hi Marco,</div>
<div class="gmail-m_8268737350121040255x_gmail_default" style="font-family:verdana,sans-serif;font-size:small">
<br>
</div>
<div class="gmail-m_8268737350121040255x_gmail_default" style="font-family:verdana,sans-serif;font-size:small">
you could combine that example with <a href="https://lorensen.github.io/VTKExamples/site/Cxx/VolumeRendering/SmartVolumeMapper/" target="_blank">
VTK VolumeRendering</a> example and connect them using <a href="https://itk.org/ITKExamples/src/Bridge/VtkGlue/ConvertAnitkImageTovtkImageData/Documentation.html" target="_blank">
ITKVTKGlue</a>.</div>
<div class="gmail-m_8268737350121040255x_gmail_default" style="font-family:verdana,sans-serif;font-size:small">
<br>
</div>
<div class="gmail-m_8268737350121040255x_gmail_default" style="font-family:verdana,sans-serif;font-size:small">
Regards,</div>
<div class="gmail-m_8268737350121040255x_gmail_default" style="font-family:verdana,sans-serif;font-size:small">
Dženan</div>
</div>
<br>
<div class="gmail-m_8268737350121040255x_gmail_quote">
<div dir="ltr" class="gmail-m_8268737350121040255x_gmail_attr">On Fri, Mar 15, 2019 at 7:00 AM Marco Festugato <<a href="mailto:marco.festugato@outlook.it" target="_blank">marco.festugato@outlook.it</a>> wrote:<br>
</div>
<blockquote class="gmail-m_8268737350121040255x_gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<font size="2"><span style="font-size:11pt"></span></font></div>
<font size="2"><span style="font-size:11pt">Hi guys! I'm very new to ITK-VTK...what i have to do is reading 199 dicom<br>
images using ITK and visualize the volume using VTK.<br>
Using the example "DicomSeriesReadImageWrite2" im able to read the series<br>
and create a 3D volume but i dont know how to visualize it with VTK! <br>
Any help? :)<br>
Thank u for your time!</span></font>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="gmail-m_8268737350121040255x_gmail-m_5822252734597398612signature">
<div id="gmail-m_8268737350121040255x_gmail-m_5822252734597398612divtagdefaultwrapper" style="font-size:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Calibri,Arial,Helvetica,sans-serif">
Inviato da <a href="http://aka.ms/weboutlook" target="_blank">Outlook</a></div>
</div>
</div>
The ITK community is transitioning from this mailing list to <a href="http://discourse.itk.org" rel="noreferrer" target="_blank">
discourse.itk.org</a>. Please join us there!<br>
________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" 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" rel="noreferrer" 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.php" rel="noreferrer" target="_blank">http://www.kitware.com/products/protraining.php</a><br>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href="http://www.itk.org/Wiki/ITK_FAQ" rel="noreferrer" target="_blank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://itk.org/mailman/listinfo/insight-users" rel="noreferrer" target="_blank">https://itk.org/mailman/listinfo/insight-users</a><br>
</blockquote>
</div>
</div>
</div>
</blockquote></div>