[Insight-users] output of segmentation to DICOM

InfoSeekerr ali.mahmoud.habib at gmail.com
Tue Mar 2 16:52:54 EST 2010


while trying to read the output of WatershedType file , how can I fix that. 
because I need the output file for vtk output 


itk::ERROR: MetaImageIO(18160008): File cannot be written: c\label.mhd
Reason: No such file or directory
Location: void __thiscall itk::MetaImageIO::Write(const void *)
File: ..\..\..\Code\IO\itkMetaImageIO.cxx
Line: 1396
   at itk.itkImage_SS3.Write(String filename)
   at itk.itkImage.Write(String filename)
   at ConsoleApplication1.Program.Main(String[] args) in C:\Users\Eng. Ali
Mahmo
ud\Documents\Visual Studio
2005\Projects\ConsoleApplication1\ConsoleApplication1
\Program.cs:line 52

I used the following code :

try
            {
                Console.WriteLine(DateTime.Now.ToShortTimeString());
                // read the DICOm series 
                itkImageBase input = itkImage_SS3.New();

                // Read the DICOM image from the given directory  
                input.ReadDicomDirectory(@"G:\Master
Degree\DataSet\case2\DICOM\PA1\ST1\SE2");

                // Display some image information
                Console.WriteLine(String.Format("Name={0}", input.Name));
                Console.WriteLine(String.Format("PixelType={0}",
input.PixelType));
                Console.WriteLine(String.Format("Dimension={0}",
input.Dimension));
                Console.WriteLine(String.Format("Size={0}", input.Size));
                Console.WriteLine(String.Format("Spacing={0}",
input.Spacing));
                Console.WriteLine(String.Format("Origin={0}",
input.Origin));
                Console.WriteLine(String.Format("Buffer={0}",
input.Buffer));

                ImageType label = itkImage.New(input.PixelType,
input.Dimension);

                // Watershed
                WatershedType filterWatershed = WatershedType.New(input);
                filterWatershed.SetInput(input);
                filterWatershed.Threshold = 0.05;
                filterWatershed.Level = 0.8;
                filterWatershed.Update();

                // Relabel
                RelabelType filterRelabel = RelabelType.New(label, label);
                filterRelabel.SetInput(filterWatershed.GetOutput());
                filterRelabel.Update();
                filterRelabel.GetOutput(label);
                input.DisconnectPipeline();
                label.DisconnectPipeline();

                // Write the label image to disk
                label.Write(@"c\label.mhd");

                      
                

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
            Console.WriteLine(DateTime.Now.ToShortTimeString());
            Console.ReadLine();

        }


Luis Ibanez wrote:
> 
> Hi Ali,
> 
> 
> 1) Regarding the output of the Watershed filter,
>     Please look at the examples:
> 
>           Insight/Examples/
>                WatershedSegmentation1.cxx
>                WatershedSegmentation2.cxx
> 
>     These examples are described in the
>     ITK Software Guide:
> 
>        http://www.itk.org/ItkSoftwareGuide.pdf
> 
> 
>     You can save the output images using the
>     MetaImage file format, or the VTK file format.
> 
>     Simply use .mhd or .vtk as filename extensions
>     respectively.
> 
> 
> 
> 2)   You could view these images with:
> 
>         a)  ParaView (www.paraview.org)
>         b)  Slicer (www.slicer.org)
> 
>       (Among others...)
> 
> 
> 3)   The classes used for connecting ITK and VTK
>        are described in the following Tutorial:
> 
> "Getting Started II: Using ITK with VTK"
> http://www.itk.org/CourseWare/Training/GettingStarted-II.pdf
> 
>        You will find the source code under
> 
>         InsightApplications/Auxiliary/vtk
> http://public.kitware.com/cgi-bin/viewcvs.cgi/Auxiliary/vtk/?root=InsightApplications
> 
> 
> 
> 4)  Regarding connecting ITK and VTK, you will also
>      find useful to look at the following Insight Journal
>      paper:
> 
>       "Seamless VTK-ITK pipeline connection for image data handling"
>       http://www.insight-journal.org/browse/publication/146
>       http://hdl.handle.net/1926/495
> 
>      The corresponding source code
>      can also be found in the directory:
> 
>         InsightApplications/Auxiliary/vtk
> http://public.kitware.com/cgi-bin/viewcvs.cgi/Auxiliary/vtk/?root=InsightApplications
> 
> 
> 
> 5)  For basic examples on how to use VTK
>      to visualize segmentation generated by ITK,
>      you may want to look at:
> 
>           InsightApplications/Auxiliary/vtk
>                  itkReadITKImage3DExtractContourVTK.cxx
>                  itkReadITKImage3DSegmentShowVTK.cxx
>                  itkReadITKImageSegmentShowVTK.cxx
>                  itkReadITKImageShowSplineVTK.cxx
>                  itkReadITKImageShowVTK.cxx
> 
> 
> 6)  You may also find useful to look at the following
>       segmentation applications that use the watershed
>       filter:
> 
>       InsightApplications/SegmentationEditor
> http://public.kitware.com/cgi-bin/viewcvs.cgi/SegmentationEditor/?root=InsightApplications
> 
>       InsightApplications/SegmentationEditorFltkGui
> http://public.kitware.com/cgi-bin/viewcvs.cgi/SegmentationEditorFltkGui/?root=InsightApplications
> 
> 
>       Both of them use the Watershed filter,
>       and both of them use VTK visualization.
> 
> 
> 
> 7) Finally,
>     Please note that CMake works fine in Windows Vista.
> 
>     You may have run into the common problem with
>     the Windows Vista UAC, that forces you to run
>     CMake (and the Visual Studio IDE) as Administrator.
> 
>     For solutions,
>     Please look at this email from the archives:
> http://www.itk.org/pipermail/insight-users/2008-May/025682.html
> 
> 
> 
>      Regards,
> 
> 
>              Luis
> 
> 
> 
> --------------------------------------------------------------------------
> On Fri, Feb 26, 2010 at 9:28 PM, Ali Habib <ali.mahmoud.habib at gmail.com>
> wrote:
>> Dear all,
>>
>> I want to save the output of wateshed segmentation  (using ITK ) and save
>> it
>> to suitable formate such that I can by using VTK  read and apply
>> vtkcontour
>> or vtkmarchingcube filter to display the 3D
>> this because I can't find the classess responsible for connecting ITK and
>> VTK piplens, and cann't use cmake in my viista PC
>>
>> best regards
>> _____________________________________
>> 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.html
>>
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>>
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
> _____________________________________
> 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.html
> 
> Please keep messages on-topic and check the ITK FAQ at:
> http://www.itk.org/Wiki/ITK_FAQ
> 
> Follow this link to subscribe/unsubscribe:
> http://www.itk.org/mailman/listinfo/insight-users
> 
> 

-- 
View this message in context: http://old.nabble.com/output-of-segmentation-to-DICOM-tp27725459p27761683.html
Sent from the ITK - Users mailing list archive at Nabble.com.



More information about the Insight-users mailing list