Re: [ITK-users] Reading DICOM series and visualize the volume with VTK

Dženan Zukić <[email protected]> Fri, 15 Mar 2019 12:58:22 -0400
Newsgroups gmane.comp.lib.itk.user
Message-ID <CAPf2UMTpC4mqigSxRJG9hjx=5SMoz9rn=COeED1EWKzRopV_iw__15607.2226747469$1552669125$gmane$org@mail.gmail.com>
--===============1745300807==
Content-Type: multipart/alternative; boundary="0000000000000abf97058424f330"

--0000000000000abf97058424f330
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi Marco,

that is more of a VTK question than ITK one, best directed at
vtkusers-+OT0MU/[email protected] Also, ITK has migrated to a new forum
<https://discourse.itk.org/>. Please post further ITK-related questions
there instead of this mailing list.

Regards,
D=C5=BEenan

On Fri, Mar 15, 2019 at 12:54 PM Marco Festugato <[email protected]=
t>
wrote:

> Hi Dzenan and thank u for your answer =F0=9F=99=82 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:
>
> reader -> connector -> mapper -> volume -> renderer -> window
>
> 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 :'(
>
>  // VTK includes
> #include "vtkDICOMImageReader.h"
> #include "vtkImageData.h"
> #include "vtkRenderer.h"
> #include "vtkRenderWindow.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkVolume.h"
> #include <vtkInteractorStyleTrackballCamera.h>
> #include <vtkVolumeProperty.h>
> #include <vtkSmartPointer.h>
> #include <vtkPiecewiseFunction.h>
> #include <vtkVolumeRayCastCompositeFunction.h>
> #include <vtkFixedPointVolumeRayCastMapper.h>
> #include <itkImage.h>
> #include <itkImageFileReader.h>
> #include <itkImageToVTKImageFilter.h>
> #include "vtkVersion.h"
> #include "vtkImageViewer.h"
> #include "vtkImageMapper3D.h"
> #include "vtkRenderWindowInteractor.h"
> #include "vtkSmartPointer.h"
> #include "vtkImageActor.h"
> #include "vtkInteractorStyleImage.h"
> #include "vtkRenderer.h"
> #include "itkImage.h"
> #include "itkGDCMImageIO.h"
> #include "itkGDCMSeriesFileNames.h"
> #include "itkImageSeriesReader.h"
> #include "itkImageFileWriter.h"
>
>  int main(int argc, char *argv[])
> {
>     // Verify the number of parameters in the command line
>     if( argc < 2)
>     {
>     std::cerr << "Usage: " << std::endl;
>     std::cerr << argv[0] << " DICOMimagesDirectory " << std::endl;
>     return EXIT_FAILURE;
>     }
>  // Software Guide : BeginCodeSnippet
>   typedef signed short    PixelType;
>   const unsigned int      Dimension =3D 3;
>   typedef itk::Image< PixelType, Dimension > ImageType;
>   typedef itk::ImageToVTKImageFilter<ImageType> ConnectorType;
>
>   ConnectorType::Pointer connector =3D ConnectorType::New();
>
> // We use the image type for instantiating the type of the series reader
> and
> // for constructing one object of its type.
>
>   typedef itk::ImageSeriesReader< ImageType >        ReaderType;
>   ReaderType::Pointer reader =3D ReaderType::New();
>
> // A GDCMImageIO object is created and connected to the reader. This
> object is
> // the one that is aware of the internal intricacies of the DICOM format.
> //
>
>   typedef itk::GDCMImageIO       ImageIOType;
>   ImageIOType::Pointer dicomIO =3D ImageIOType::New();
>
>   reader->SetImageIO( dicomIO );
>
>   using NamesGeneratorType =3D itk::GDCMSeriesFileNames;
>   NamesGeneratorType::Pointer nameGenerator =3D NamesGeneratorType::New()=
;
>
>   nameGenerator->SetUseSeriesDetails( true );
>   nameGenerator->SetDirectory( argv[1] );
>
>   try
>     {
>     std::cout << std::endl << "The directory: " << std::endl;
>     std::cout << std::endl << argv[1] << std::endl << std::endl;
>     std::cout << "Contains the following DICOM Series: ";
>     std::cout << std::endl << std::endl;
>
>
> // Software Guide : BeginLatex
> //
> // The GDCMSeriesFileNames object first identifies the list of DICOM seri=
es
> // present in the given directory. We receive that list in a reference
> // to a container of strings and then we can do things like print out all
> // the series identifiers that the generator had found. Since the process
> of
> // finding the series identifiers can potentially throw exceptions, it is
> // wise to put this code inside a \code{try/catch} block.
> //
>
>
>     typedef std::vector< std::string >    SeriesIdContainer;
>
>     const SeriesIdContainer & seriesUID =3D nameGenerator->GetSeriesUIDs(=
);
>
> // Given that it is common to find multiple DICOM series in the same
> directory,
> // we must tell the GDCM classes what specific series we want to read. In
> // this example we do this by checking first if the user has provided a
> series
> // identifier in the command line arguments. If no series identifier has
> been
> // passed, then we simply use the first series found during the
> exploration of
> // the directory.
>
>
>     std::string seriesIdentifier;
>
>      seriesIdentifier =3D seriesUID.begin()->c_str();
>
>     std::cout << std::endl << std::endl;
>     std::cout << "Now reading series: " << std::endl << std::endl;
>     std::cout << seriesIdentifier << std::endl;
>     std::cout << std::endl << std::endl;
>
>
> // We pass the series identifier to the name generator and ask for all th=
e
> // filenames associated to that series. This list is returned in a
> container of
> // strings by the \code{GetFileNames()} method.
>
>
>     typedef std::vector< std::string >   FileNamesContainer;
>     FileNamesContainer fileNames;
>
>     fileNames =3D nameGenerator->GetFileNames( seriesIdentifier );
>
> //
> // The list of filenames can now be passed to the
> \doxygen{ImageSeriesReader}
> // using the \code{SetFileNames()} method.
>
>
>     reader->SetFileNames( fileNames );
>
> // Finally we can trigger the reading process by invoking the
> \code{Update()}
> // method in the reader. This call as usual is placed inside a
> \code{try/catch}
> // block.
>
>     try
>       {
>       reader->Update();
>       }
>     catch (itk::ExceptionObject &ex)
>       {
>       std::cout << ex << std::endl;
>       return EXIT_FAILURE;
>       }
> }
>   catch (itk::ExceptionObject &ex)
>     {
>     std::cout << ex << std::endl;
>     return EXIT_FAILURE;
>     }
>
>   // Visualization pipeline
>
>     // Create the renderer, render window and interactor
>    vtkRenderer *renderer =3D vtkRenderer::New();
>    vtkRenderWindow *renWin =3D vtkRenderWindow::New();
>    renWin->AddRenderer(renderer);
>
>     vtkRenderWindowInteractor *iren =3D vtkRenderWindowInteractor::New();
>     iren->SetRenderWindow(renWin);
>
>    // Read the data
>    vtkImageData *input =3D nullptr;
>
> /*    vtkDICOMImageReader *reader =3D vtkDICOMImageReader::New();
> // vtkTIFFReader *reader =3D vtkTIFFReader::New();
>    reader->SetFileName(argv[1]); */
>    // reader->Update(); // read data
>
>
>    connector->SetInput(reader->GetOutput());
>
>     // Create our volume and mapper
>     vtkVolume *volume =3D vtkVolume::New();
>     vtkFixedPointVolumeRayCastMapper *mapper =3D
> vtkFixedPointVolumeRayCastMapper::New();
> // vtkVolumeRayCastCompositeFunction *compositeFunction =3D
> vtkVolumeRayCastCompositeFunction::New();
> vtkInteractorStyleTrackballCamera *styleCamera =3D
> vtkInteractorStyleTrackballCamera::New();
>
>     // connect up the volume to the property and the mapper
>     mapper -> SetInputData( connector -> GetOutput() );
> mapper -> SetSampleDistance( 0.1 );
>
> vtkSmartPointer<vtkVolumeProperty> volumeProperty =3D
> vtkSmartPointer<vtkVolumeProperty>::New();
>
>
> volumeProperty->SetInterpolationTypeToLinear(); // better image quality
> but computation's longer
>
>
> vtkSmartPointer<vtkPiecewiseFunction> scalarOpacity =3D
> vtkSmartPointer<vtkPiecewiseFunction>::New();
> vtkSmartPointer<vtkPiecewiseFunction> gradientOpacity =3D
> vtkSmartPointer<vtkPiecewiseFunction>::New();
>
>   scalarOpacity->AddPoint(0,    0.00);
>   scalarOpacity->AddPoint(500,  0.15);
>   scalarOpacity->AddPoint(1000, 0.15);
>   scalarOpacity->AddPoint(1150, 0.85);
>
>
>   gradientOpacity->AddPoint(0,   0.0);
>   gradientOpacity->AddPoint(90,  0.5);
>   gradientOpacity->AddPoint(100, 1.0);
>
>
> //set the transfer functions to the property
> volumeProperty->SetScalarOpacity(scalarOpacity);
> volumeProperty->SetGradientOpacity(gradientOpacity);
>
> //set the property to the volume
>
> volume->SetProperty(volumeProperty);
>
> volume->SetMapper( mapper );
>     iren -> SetInteractorStyle(styleCamera);
>     // Set the default window size
>     renWin->SetSize(600,600);
>
>     // Add the volume to the scene
>     renderer->AddVolume( volume );
>
>     // interact with data
>     renWin->Render();
>     iren -> Start();
>
>
>     return EXIT_SUCCESS;
>   }
>
>
>
> Inviato da Outlook <http://aka.ms/weboutlook>
> ------------------------------
> *Da:* D=C5=BEenan Zuki=C4=87 <[email protected]>
> *Inviato:* venerd=C3=AC 15 marzo 2019 17:19
> *A:* Marco Festugato
> *Cc:* [email protected]
> *Oggetto:* Re: [ITK-users] Reading DICOM series and visualize the volume
> with VTK
>
> Hi Marco,
>
> you could combine that example with VTK VolumeRendering
> <https://lorensen.github.io/VTKExamples/site/Cxx/VolumeRendering/SmartVol=
umeMapper/> example
> and connect them using ITKVTKGlue
> <https://itk.org/ITKExamples/src/Bridge/VtkGlue/ConvertAnitkImageTovtkIma=
geData/Documentation.html>
> .
>
> Regards,
> D=C5=BEenan
>
> On Fri, Mar 15, 2019 at 7:00 AM Marco Festugato <
> [email protected]> wrote:
>
> Hi guys! I'm very new to ITK-VTK...what i have to do is reading 199 dicom
> images using ITK and visualize the volume using VTK.
> Using the example "DicomSeriesReadImageWrite2" im able to read the series
> and create a 3D volume but i dont know how to visualize it with VTK!
> Any help? :)
> Thank u for your time!
>
> Inviato da Outlook <http://aka.ms/weboutlook>
> The ITK community is transitioning from this mailing list to
> discourse.itk.org. Please join us there!
> ________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Kitware offers ITK Training Courses, for more information visit:
> http://www.kitware.com/products/protraining.php
>
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> https://itk.org/mailman/listinfo/insight-users
>
>

--0000000000000abf97058424f330
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><div class=3D"gmail_default" style=3D"fon=
t-family:verdana,sans-serif;font-size:small">Hi Marco,</div><div class=3D"g=
mail_default" style=3D"font-family:verdana,sans-serif;font-size:small"><br>=
</div><div class=3D"gmail_default" style=3D"font-family:verdana,sans-serif;=
font-size:small">that is more of a VTK question than ITK one, best directed=
 at=C2=A0<a href=3D"mailto:[email protected]">[email protected]</a>. Also, IT=
K has migrated to a new <a href=3D"https://discourse.itk.org/">forum</a>. P=
lease post further ITK-related questions there instead of this mailing list=
.</div><div class=3D"gmail_default" style=3D"font-family:verdana,sans-serif=
;font-size:small"><br></div><div class=3D"gmail_default" style=3D"font-fami=
ly:verdana,sans-serif;font-size:small">Regards,</div><div class=3D"gmail_de=
fault" style=3D"font-family:verdana,sans-serif;font-size:small">D=C5=BEenan=
</div></div></div><br><div class=3D"gmail_quote"><div dir=3D"ltr" class=3D"=
gmail_attr">On Fri, Mar 15, 2019 at 12:54 PM Marco Festugato &lt;<a href=3D=
"mailto:[email protected]">[email protected]</a>&gt; wrot=
e:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0=
.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">




<div dir=3D"ltr">
<div style=3D"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=3D"gmail-m_82687373501210402=
55=F0=9F=99=82" title=3D":lieve_sorriso:">=F0=9F=99=82</span> I&#39;ve trie=
d to do as u suggested, but i receive an error telling me that my mapper do=
esnt accept &#39;&#39;scalar cells&#39;&#39;...maybe this connector doesnt =
work with my mapper? i&#39;ve tried
 to simply add the &#39;connector&#39; to my pipeline:<br>
</div>
<div style=3D"font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt=
;color:rgb(0,0,0)">
<br>
</div>
<div style=3D"font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt=
;color:rgb(0,0,0)">
reader -&gt; connector -&gt; mapper -&gt; volume -&gt; renderer -&gt; windo=
w</div>
<div style=3D"font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt=
;color:rgb(0,0,0)">
<br>
</div>
<div style=3D"font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt=
;color:rgb(0,0,0)">
Here&#39;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 :&#39;(
<br>
</div>
<div style=3D"font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt=
;color:rgb(0,0,0)">
<br>
</div>
<div style=3D"font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt=
;color:rgb(0,0,0)">
<span>=C2=A0// VTK includes<br>
</span>
<div>#include &quot;vtkDICOMImageReader.h&quot;<br>
</div>
<div>#include &quot;vtkImageData.h&quot;<br>
</div>
<div>#include &quot;vtkRenderer.h&quot;<br>
</div>
<div>#include &quot;vtkRenderWindow.h&quot;<br>
</div>
<div>#include &quot;vtkRenderWindowInteractor.h&quot;<br>
</div>
<div>#include &quot;vtkVolume.h&quot;<br>
</div>
<div>#include &lt;vtkInteractorStyleTrackballCamera.h&gt;<br>
</div>
<div>#include &lt;vtkVolumeProperty.h&gt;<br>
</div>
<div>#include &lt;vtkSmartPointer.h&gt;<br>
</div>
<div>#include &lt;vtkPiecewiseFunction.h&gt;<br>
</div>
<div>#include &lt;vtkVolumeRayCastCompositeFunction.h&gt;<br>
</div>
<div>#include &lt;vtkFixedPointVolumeRayCastMapper.h&gt;<br>
</div>
<div>#include &lt;itkImage.h&gt;<br>
</div>
<div>#include &lt;itkImageFileReader.h&gt;<br>
</div>
<div>#include &lt;itkImageToVTKImageFilter.h&gt;<br>
</div>
<div>#include &quot;vtkVersion.h&quot;<br>
</div>
<div>#include &quot;vtkImageViewer.h&quot;<br>
</div>
<div>#include &quot;vtkImageMapper3D.h&quot;<br>
</div>
<div>#include &quot;vtkRenderWindowInteractor.h&quot;<br>
</div>
<div>#include &quot;vtkSmartPointer.h&quot;<br>
</div>
<div>#include &quot;vtkImageActor.h&quot;<br>
</div>
<div>#include &quot;vtkInteractorStyleImage.h&quot;<br>
</div>
<div>#include &quot;vtkRenderer.h&quot;<br>
</div>
<div>#include &quot;itkImage.h&quot;<br>
</div>
<div>#include &quot;itkGDCMImageIO.h&quot;<br>
</div>
<div>#include &quot;itkGDCMSeriesFileNames.h&quot;<br>
</div>
<div>#include &quot;itkImageSeriesReader.h&quot;<br>
</div>
<div>#include &quot;itkImageFileWriter.h&quot;<br>
</div>
<div><br>
</div>
<div>=C2=A0int main(int argc, char *argv[])<br>
</div>
<div>{<br>
</div>
<div>=C2=A0 =C2=A0 // Verify the number of parameters in the command line<b=
r>
</div>
<div>=C2=A0 =C2=A0 if( argc &lt; 2)<br>
</div>
<div>=C2=A0 =C2=A0 {<br>
</div>
<div>=C2=A0 =C2=A0 std::cerr &lt;&lt; &quot;Usage: &quot; &lt;&lt; std::end=
l;<br>
</div>
<div>=C2=A0 =C2=A0 std::cerr &lt;&lt; argv[0] &lt;&lt; &quot; DICOMimagesDi=
rectory &quot; &lt;&lt; std::endl;<br>
</div>
<div>=C2=A0 =C2=A0 return EXIT_FAILURE;<br>
</div>
<div>=C2=A0 =C2=A0 }<br>
</div>
<div>=C2=A0// Software Guide : BeginCodeSnippet<br>
</div>
<div>=C2=A0 typedef signed short =C2=A0 =C2=A0PixelType;<br>
</div>
<div>=C2=A0 const unsigned int =C2=A0 =C2=A0 =C2=A0Dimension =3D 3;<br>
</div>
<div>=C2=A0 typedef itk::Image&lt; PixelType, Dimension &gt; ImageType;<br>
</div>
<div>=C2=A0 typedef itk::ImageToVTKImageFilter&lt;ImageType&gt; ConnectorTy=
pe;<br>
</div>
<div><br>
</div>
<div>=C2=A0 ConnectorType::Pointer connector =3D ConnectorType::New();<br>
</div>
<div>=C2=A0 <br>
</div>
<div>// We use the image type for instantiating the type of the series read=
er and<br>
</div>
<div>// for constructing one object of its type.<br>
</div>
<div><br>
</div>
<div>=C2=A0 typedef itk::ImageSeriesReader&lt; ImageType &gt; =C2=A0 =C2=A0=
 =C2=A0 =C2=A0ReaderType;<br>
</div>
<div>=C2=A0 ReaderType::Pointer reader =3D ReaderType::New();<br>
</div>
<div><br>
</div>
<div>// A GDCMImageIO object is created and connected to the reader. This o=
bject is<br>
</div>
<div>// the one that is aware of the internal intricacies of the DICOM form=
at.<br>
</div>
<div>//<br>
</div>
<div><br>
</div>
<div>=C2=A0 typedef itk::GDCMImageIO =C2=A0 =C2=A0 =C2=A0 ImageIOType;<br>
</div>
<div>=C2=A0 ImageIOType::Pointer dicomIO =3D ImageIOType::New();<br>
</div>
<div><br>
</div>
<div>=C2=A0 reader-&gt;SetImageIO( dicomIO );<br>
</div>
<div><br>
</div>
<div>=C2=A0 using NamesGeneratorType =3D itk::GDCMSeriesFileNames;<br>
</div>
<div>=C2=A0 NamesGeneratorType::Pointer nameGenerator =3D NamesGeneratorTyp=
e::New();<br>
</div>
<div><br>
</div>
<div>=C2=A0 nameGenerator-&gt;SetUseSeriesDetails( true ); <br>
</div>
<div>=C2=A0 nameGenerator-&gt;SetDirectory( argv[1] ); <br>
</div>
<div><br>
</div>
<div>=C2=A0 try<br>
</div>
<div>=C2=A0 =C2=A0 {<br>
</div>
<div>=C2=A0 =C2=A0 std::cout &lt;&lt; std::endl &lt;&lt; &quot;The director=
y: &quot; &lt;&lt; std::endl;<br>
</div>
<div>=C2=A0 =C2=A0 std::cout &lt;&lt; std::endl &lt;&lt; argv[1] &lt;&lt; s=
td::endl &lt;&lt; std::endl;<br>
</div>
<div>=C2=A0 =C2=A0 std::cout &lt;&lt; &quot;Contains the following DICOM Se=
ries: &quot;;<br>
</div>
<div>=C2=A0 =C2=A0 std::cout &lt;&lt; std::endl &lt;&lt; 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 s=
eries<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 proc=
ess 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>=C2=A0 =C2=A0 typedef std::vector&lt; std::string &gt; =C2=A0 =C2=A0Se=
riesIdContainer;<br>
</div>
<div><br>
</div>
<div>=C2=A0 =C2=A0 const SeriesIdContainer &amp; seriesUID =3D nameGenerato=
r-&gt;GetSeriesUIDs();<br>
</div>
<div><br>
</div>
<div>// Given that it is common to find multiple DICOM series in the same d=
irectory,<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 h=
as been<br>
</div>
<div>// passed, then we simply use the first series found during the explor=
ation of<br>
</div>
<div>// the directory.<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>=C2=A0 =C2=A0 std::string seriesIdentifier;<br>
</div>
<div><br>
</div>
<div>=C2=A0 =C2=A0=C2=A0 seriesIdentifier =3D seriesUID.begin()-&gt;c_str()=
;<br>
</div>
<div><br>
</div>
<div>=C2=A0 =C2=A0 std::cout &lt;&lt; std::endl &lt;&lt; std::endl;<br>
</div>
<div>=C2=A0 =C2=A0 std::cout &lt;&lt; &quot;Now reading series: &quot; &lt;=
&lt; std::endl &lt;&lt; std::endl;<br>
</div>
<div>=C2=A0 =C2=A0 std::cout &lt;&lt; seriesIdentifier &lt;&lt; std::endl;<=
br>
</div>
<div>=C2=A0 =C2=A0 std::cout &lt;&lt; std::endl &lt;&lt; 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 con=
tainer of<br>
</div>
<div>// strings by the \code{GetFileNames()} method.<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>=C2=A0 =C2=A0 typedef std::vector&lt; std::string &gt; =C2=A0 FileName=
sContainer;<br>
</div>
<div>=C2=A0 =C2=A0 FileNamesContainer fileNames;<br>
</div>
<div><br>
</div>
<div>=C2=A0 =C2=A0 fileNames =3D nameGenerator-&gt;GetFileNames( seriesIden=
tifier );<br>
</div>
<div><br>
</div>
<div>//<br>
</div>
<div>// The list of filenames can now be passed to the \doxygen{ImageSeries=
Reader}<br>
</div>
<div>// using the \code{SetFileNames()} method.<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>=C2=A0 =C2=A0 reader-&gt;SetFileNames( fileNames );<br>
</div>
<div><br>
</div>
<div>// Finally we can trigger the reading process by invoking the \code{Up=
date()}<br>
</div>
<div>// method in the reader. This call as usual is placed inside a \code{t=
ry/catch}<br>
</div>
<div>// block.<br>
</div>
<div><br>
</div>
<div>=C2=A0 =C2=A0 try<br>
</div>
<div>=C2=A0 =C2=A0 =C2=A0 {<br>
</div>
<div>=C2=A0 =C2=A0 =C2=A0 reader-&gt;Update();<br>
</div>
<div>=C2=A0 =C2=A0 =C2=A0 }<br>
</div>
<div>=C2=A0 =C2=A0 catch (itk::ExceptionObject &amp;ex)<br>
</div>
<div>=C2=A0 =C2=A0 =C2=A0 {<br>
</div>
<div>=C2=A0 =C2=A0 =C2=A0 std::cout &lt;&lt; ex &lt;&lt; std::endl;<br>
</div>
<div>=C2=A0 =C2=A0 =C2=A0 return EXIT_FAILURE;<br>
</div>
<div>=C2=A0 =C2=A0 =C2=A0 }<br>
</div>
<div>}<br>
</div>
<div>=C2=A0 catch (itk::ExceptionObject &amp;ex)<br>
</div>
<div>=C2=A0 =C2=A0 {<br>
</div>
<div>=C2=A0 =C2=A0 std::cout &lt;&lt; ex &lt;&lt; std::endl;<br>
</div>
<div>=C2=A0 =C2=A0 return EXIT_FAILURE;<br>
</div>
<div>=C2=A0 =C2=A0 }<br>
</div>
<div><br>
</div>
<div>=C2=A0 // Visualization pipeline<br>
</div>
<div><br>
</div>
<div>=C2=A0 =C2=A0 // Create the renderer, render window and interactor<br>
</div>
<div>=C2=A0 =C2=A0vtkRenderer *renderer =3D vtkRenderer::New();<br>
</div>
<div>=C2=A0 =C2=A0vtkRenderWindow *renWin =3D vtkRenderWindow::New();<br>
</div>
<div>=C2=A0 =C2=A0renWin-&gt;AddRenderer(renderer);<br>
</div>
<div>=C2=A0<br>
</div>
<div>=C2=A0 =C2=A0 vtkRenderWindowInteractor *iren =3D vtkRenderWindowInter=
actor::New();<br>
</div>
<div>=C2=A0 =C2=A0 iren-&gt;SetRenderWindow(renWin);<br>
</div>
<div>=C2=A0<br>
</div>
<div>=C2=A0 =C2=A0// Read the data<br>
</div>
<div>=C2=A0 =C2=A0vtkImageData *input =3D nullptr;<br>
</div>
<div><br>
</div>
<div>/* =C2=A0 =C2=A0vtkDICOMImageReader *reader =3D vtkDICOMImageReader::N=
ew();<br>
</div>
<div>// vtkTIFFReader *reader =3D vtkTIFFReader::New();<br>
</div>
<div>=C2=A0 =C2=A0reader-&gt;SetFileName(argv[1]); */<br>
</div>
<div>=C2=A0 =C2=A0// reader-&gt;Update(); // read data<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>=C2=A0 =C2=A0connector-&gt;SetInput(reader-&gt;GetOutput());<br>
</div>
<div>=C2=A0 =C2=A0<br>
</div>
<div>=C2=A0 =C2=A0 // Create our volume and mapper<br>
</div>
<div>=C2=A0 =C2=A0 vtkVolume *volume =3D vtkVolume::New();<br>
</div>
<div>=C2=A0 =C2=A0 vtkFixedPointVolumeRayCastMapper *mapper =3D vtkFixedPoi=
ntVolumeRayCastMapper::New();<br>
</div>
<div>// vtkVolumeRayCastCompositeFunction *compositeFunction =3D vtkVolumeR=
ayCastCompositeFunction::New();<br>
</div>
<div>vtkInteractorStyleTrackballCamera *styleCamera =3D vtkInteractorStyleT=
rackballCamera::New();<br>
</div>
<div><br>
</div>
<div>=C2=A0 =C2=A0 // connect up the volume to the property and the mapper<=
br>
</div>
<div>=C2=A0 =C2=A0 mapper -&gt; SetInputData( connector -&gt; GetOutput() )=
;<br>
</div>
<div>mapper -&gt; SetSampleDistance( 0.1 );<br>
</div>
<div><br>
</div>
<div>vtkSmartPointer&lt;vtkVolumeProperty&gt; volumeProperty =3D vtkSmartPo=
inter&lt;vtkVolumeProperty&gt;::New();<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>volumeProperty-&gt;SetInterpolationTypeToLinear(); // better image qua=
lity but computation&#39;s longer<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>vtkSmartPointer&lt;vtkPiecewiseFunction&gt; scalarOpacity =3D vtkSmart=
Pointer&lt;vtkPiecewiseFunction&gt;::New();<br>
</div>
<div>vtkSmartPointer&lt;vtkPiecewiseFunction&gt; gradientOpacity =3D vtkSma=
rtPointer&lt;vtkPiecewiseFunction&gt;::New();<br>
</div>
<div><br>
</div>
<div>=C2=A0 scalarOpacity-&gt;AddPoint(0, =C2=A0 =C2=A00.00);<br>
</div>
<div>=C2=A0 scalarOpacity-&gt;AddPoint(500, =C2=A00.15);<br>
</div>
<div>=C2=A0 scalarOpacity-&gt;AddPoint(1000, 0.15);<br>
</div>
<div>=C2=A0 scalarOpacity-&gt;AddPoint(1150, 0.85);<br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>=C2=A0 gradientOpacity-&gt;AddPoint(0, =C2=A0 0.0);<br>
</div>
<div>=C2=A0 gradientOpacity-&gt;AddPoint(90, =C2=A00.5);<br>
</div>
<div>=C2=A0 gradientOpacity-&gt;AddPoint(100, 1.0);<br>
</div>
<br>
<div><br>
</div>
<div>//set the transfer functions to the property<br>
</div>
<div>volumeProperty-&gt;SetScalarOpacity(scalarOpacity);<br>
</div>
<div>volumeProperty-&gt;SetGradientOpacity(gradientOpacity);<br>
</div>
<div><br>
</div>
<div>//set the property to the volume<br>
</div>
<div><br>
</div>
<div>volume-&gt;SetProperty(volumeProperty);<br>
</div>
<div><br>
</div>
<div>volume-&gt;SetMapper( mapper );<br>
</div>
<div>=C2=A0 =C2=A0 iren -&gt; SetInteractorStyle(styleCamera);<br>
</div>
<div>=C2=A0 =C2=A0 // Set the default window size<br>
</div>
<div>=C2=A0 =C2=A0 renWin-&gt;SetSize(600,600);<br>
</div>
<div>=C2=A0<br>
</div>
<div>=C2=A0 =C2=A0 // Add the volume to the scene<br>
</div>
<div>=C2=A0 =C2=A0 renderer-&gt;AddVolume( volume );<br>
</div>
<div>=C2=A0 =C2=A0<br>
</div>
<div>=C2=A0 =C2=A0 // interact with data<br>
</div>
<div>=C2=A0 =C2=A0 renWin-&gt;Render();<br>
</div>
<div>=C2=A0 =C2=A0 iren -&gt; Start();<br>
</div>
<div><br>
</div>
<div>=C2=A0<br>
</div>
<div>=C2=A0 =C2=A0 return EXIT_SUCCESS;<br>
</div>
<div>=C2=A0 }<br>
</div>
<div><br>
</div>
<span></span><br>
</div>
<div style=3D"font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt=
;color:rgb(0,0,0)">
<br>
</div>
<div id=3D"gmail-m_8268737350121040255signature">
<div id=3D"gmail-m_8268737350121040255divtagdefaultwrapper" style=3D"font-s=
ize:12pt;color:rgb(0,0,0);background-color:rgb(255,255,255);font-family:Cal=
ibri,Arial,Helvetica,sans-serif">
Inviato da <a href=3D"http://aka.ms/weboutlook" target=3D"_blank">Outlook</=
a></div>
</div>
<div id=3D"gmail-m_8268737350121040255appendonsend"></div>
<hr style=3D"display:inline-block;width:98%">
<div id=3D"gmail-m_8268737350121040255divRplyFwdMsg" dir=3D"ltr"><font face=
=3D"Calibri, sans-serif" style=3D"font-size:11pt" color=3D"#000000"><b>Da:<=
/b> D=C5=BEenan Zuki=C4=87 &lt;<a href=3D"mailto:[email protected]" target=
=3D"_blank">[email protected]</a>&gt;<br>
<b>Inviato:</b> venerd=C3=AC 15 marzo 2019 17:19<br>
<b>A:</b> Marco Festugato<br>
<b>Cc:</b> <a href=3D"mailto:[email protected]" target=3D"_blank">insig=
[email protected]</a><br>
<b>Oggetto:</b> Re: [ITK-users] Reading DICOM series and visualize the volu=
me with VTK</font>
<div>=C2=A0</div>
</div>
<div>
<div dir=3D"ltr">
<div class=3D"gmail-m_8268737350121040255x_gmail_default" style=3D"font-fam=
ily:verdana,sans-serif;font-size:small">
Hi Marco,</div>
<div class=3D"gmail-m_8268737350121040255x_gmail_default" style=3D"font-fam=
ily:verdana,sans-serif;font-size:small">
<br>
</div>
<div class=3D"gmail-m_8268737350121040255x_gmail_default" style=3D"font-fam=
ily:verdana,sans-serif;font-size:small">
you could combine that example with <a href=3D"https://lorensen.github.io/V=
TKExamples/site/Cxx/VolumeRendering/SmartVolumeMapper/" target=3D"_blank">
VTK VolumeRendering</a>=C2=A0example and connect them using <a href=3D"http=
s://itk.org/ITKExamples/src/Bridge/VtkGlue/ConvertAnitkImageTovtkImageData/=
Documentation.html" target=3D"_blank">
ITKVTKGlue</a>.</div>
<div class=3D"gmail-m_8268737350121040255x_gmail_default" style=3D"font-fam=
ily:verdana,sans-serif;font-size:small">
<br>
</div>
<div class=3D"gmail-m_8268737350121040255x_gmail_default" style=3D"font-fam=
ily:verdana,sans-serif;font-size:small">
Regards,</div>
<div class=3D"gmail-m_8268737350121040255x_gmail_default" style=3D"font-fam=
ily:verdana,sans-serif;font-size:small">
D=C5=BEenan</div>
</div>
<br>
<div class=3D"gmail-m_8268737350121040255x_gmail_quote">
<div dir=3D"ltr" class=3D"gmail-m_8268737350121040255x_gmail_attr">On Fri, =
Mar 15, 2019 at 7:00 AM Marco Festugato &lt;<a href=3D"mailto:marco.festuga=
[email protected]" target=3D"_blank">[email protected]</a>&gt; wrote:<=
br>
</div>
<blockquote class=3D"gmail-m_8268737350121040255x_gmail_quote" style=3D"mar=
gin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1=
ex">
<div dir=3D"ltr">
<div style=3D"font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt=
;color:rgb(0,0,0)">
<font size=3D"2"><span style=3D"font-size:11pt"></span></font></div>
<font size=3D"2"><span style=3D"font-size:11pt">Hi guys! I&#39;m very new t=
o 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 &quot;DicomSeriesReadImageWrite2&quot; im able to read th=
e 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=3D"font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt=
;color:rgb(0,0,0)">
<br>
</div>
<div id=3D"gmail-m_8268737350121040255x_gmail-m_5822252734597398612signatur=
e">
<div id=3D"gmail-m_8268737350121040255x_gmail-m_5822252734597398612divtagde=
faultwrapper" style=3D"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=3D"http://aka.ms/weboutlook" target=3D"_blank">Outlook</=
a></div>
</div>
</div>
The ITK community is transitioning from this mailing list to <a href=3D"htt=
p://discourse.itk.org" rel=3D"noreferrer" target=3D"_blank">
discourse.itk.org</a>. Please join us there!<br>
________________________________<br>
Powered by <a href=3D"http://www.kitware.com" rel=3D"noreferrer" target=3D"=
_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at<br>
<a href=3D"http://www.kitware.com/opensource/opensource.html" rel=3D"norefe=
rrer" target=3D"_blank">http://www.kitware.com/opensource/opensource.html</=
a><br>
<br>
Kitware offers ITK Training Courses, for more information visit:<br>
<a href=3D"http://www.kitware.com/products/protraining.php" rel=3D"noreferr=
er" target=3D"_blank">http://www.kitware.com/products/protraining.php</a><b=
r>
<br>
Please keep messages on-topic and check the ITK FAQ at:<br>
<a href=3D"http://www.itk.org/Wiki/ITK_FAQ" rel=3D"noreferrer" target=3D"_b=
lank">http://www.itk.org/Wiki/ITK_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href=3D"https://itk.org/mailman/listinfo/insight-users" rel=3D"noreferre=
r" target=3D"_blank">https://itk.org/mailman/listinfo/insight-users</a><br>
</blockquote>
</div>
</div>
</div>

</blockquote></div>

--0000000000000abf97058424f330--

--===============1745300807==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

The ITK community is transitioning from this mailing list to discourse.itk.org. Please join us there!
________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at
http://www.kitware.com/opensource/opensource.html

Kitware offers ITK Training Courses, for more information visit:
http://www.kitware.com/products/protraining.php

Please keep messages on-topic and check the ITK FAQ at:
http://www.itk.org/Wiki/ITK_FAQ

Follow this link to subscribe/unsubscribe:
https://itk.org/mailman/listinfo/insight-users

--===============1745300807==--