[Insight-users] I want to segment blood vessels from a series of picture with ITK , please help me
Matt McCormick
matt.mccormick at kitware.com
Wed Aug 7 17:54:43 EDT 2013
Hi zhq,
To stream, the StreamingImageFilter must come at the end of the pipeline,
and intermediate calls to Update() should be avoided. Here is an example
[1].
Please keep messages on the list.
Thanks,
Matt
[1]
http://itk.org/ITKExamples/src/Core/Common/StreamAPipeline/Documentation.html
On Sun, Aug 4, 2013 at 2:04 AM, zhq <15891495523 at 126.com> wrote:
> Hello :
> I have tried the StreamingImageFilter , it doesn't work ! The MR
> files are attached to the email (contains 50 files). And my code is :
> (I want to know where is the problem at all ! I'm going mad . )
> //use the itkHessian3DToVesselnessMeasureImageFilter method to segment
> //bright blood vessel
> #include "itkImage.h"
> #include "itkImageSeriesReader.h"
> #include "itkImageFileWriter.h"
> #include "itkNumericSeriesFileNames.h"
> #include "itkGDCMImageIO.h"
> #include <Windows.h>
> #include "itkShiftScaleImageFilter.h"
> #include "itkHessianRecursiveGaussianImageFilter.h"
> #include "itkHessian3DToVesselnessMeasureImageFilter.h"
> #include "itkStreamingImageFilter.h"
> void main()
> {
> typedef unsigned short PixelType ;
> const unsigned int Dimension = 3;
> typedef itk::Image<PixelType , Dimension> ImageType ;
> typedef itk::ImageSeriesReader<ImageType> ReaderType ;
> //there still some parameters can be set
> typedef itk::NumericSeriesFileNames NameGeneratorType ;
> NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
>
> nameGenerator->SetSeriesFormat("C:\\Users\\zhq\\Desktop\\data\\SNAP_CR\\E403434298\\E403434298S1901I%3d.dcm");
> nameGenerator->SetStartIndex(301);
> nameGenerator->SetEndIndex(344);
> nameGenerator->SetIncrementIndex(1);
> ReaderType::Pointer reader = ReaderType::New();
> reader->SetImageIO(itk::GDCMImageIO::New());
> reader->SetFileNames(nameGenerator->GetFileNames());
> reader->Update();
> std::cout<<"reader updata"<<std::endl;
>
> typedef itk::StreamingImageFilter<ImageType,ImageType> StreamFilterType ;
> StreamFilterType::Pointer StreamFilter = StreamFilterType::New();
> StreamFilter->SetInput(reader->GetOutput());
> StreamFilter->SetNumberOfStreamDivisions(10);
> StreamFilter->Update();
>
> typedef itk::Image<double,3> doubleImageType ;
> typedef itk::ShiftScaleImageFilter<ImageType,doubleImageType> ShiftFilter
> ;
> ShiftFilter::Pointer filter = ShiftFilter::New();
> filter->SetInput(StreamFilter->GetOutput());
> filter->Update();
> std::cout<<"filter updata"<<std::endl ;
>
> typedef itk::HessianRecursiveGaussianImageFilter<doubleImageType>
> HessianFilterType;
> HessianFilterType::Pointer hessianFilter = HessianFilterType::New();
> hessianFilter->SetInput(filter->GetOutput());
> hessianFilter->Update();
> std::cout<<"hessian Filter"<<std::endl ;
>
> //if read 45 files , there is a error
> typedef itk::Hessian3DToVesselnessMeasureImageFilter<float>
> VesselMeasureFilterType ;
> VesselMeasureFilterType::Pointer vesselFilter =
> VesselMeasureFilterType::New();
> vesselFilter->SetInput(hessianFilter->GetOutput());
> vesselFilter->Update();
> std::cout<<"vesselFilter update"<<std::endl;
>
> typedef itk::ImageFileWriter< itk::Image<float,3> > WriterType ;
> WriterType::Pointer writer = WriterType::New();
> writer->SetInput(vesselFilter->GetOutput());
> writer->SetFileName("C:\\Users\\zhq\\Desktop\\Hessiandata.vtk");
> writer->Update();
> std::cout<<"writer updata"<<std::endl ;
>
> system("pause");
> }
>
>
>
>
>
> At 2013-08-04 05:05:33,"Matt McCormick" <matt.mccormick at kitware.com>
> wrote:
>
> Hi zhq,
>
> It may be that you are running out of memory. If that is the case,
> streaming can be applied to process the image in small chunks. This can be
> achived with the StreamingImageFilter [1] or SetNumberOfStreamDivisions [2]
> on ImageFileWriter.
>
> Thanks,
> Matt
>
> [1] http://www.itk.org/Doxygen/html/classitk_1_1StreamingImageFilter.html
> [2]
> http://www.itk.org/Doxygen/html/classitk_1_1ImageFileWriter.html#a3dc8330ca50ef60844a15c1a81cc6ade
>
> On Fri, Aug 2, 2013 at 8:46 PM, zhq <15891495523 at 126.com> wrote:
>
>> Hello :
>> I must make an apology for my yesterday email .
>> With referencing to the [1] , I can successfully segment blood
>> vessels . Thank you very much . Although the result isn't very well , it
>> help me a lot .
>> But , there still a problem . I have 100 dicom files , and I thought
>> read 100 files , and then segment those files . But , if I read more then
>> 43 files , an error happened .
>> My code and the error are shown as follow .
>>
>> my code :
>> //use the itkHessian3DToVesselnessMeasureImageFilter method to segment
>> //bright blood vessel
>> #include "itkImage.h"
>> #include "itkImageSeriesReader.h"
>> #include "itkImageFileWriter.h"
>> #include "itkNumericSeriesFileNames.h"
>> #include "itkGDCMImageIO.h"
>> #include <Windows.h>
>> #include "itkShiftScaleImageFilter.h"
>> #include "itkHessianRecursiveGaussianImageFilter.h"
>> #include "itkHessian3DToVesselnessMeasureImageFilter.h"
>> void main()
>> {
>> typedef unsigned short PixelType ;
>> const unsigned int Dimension = 3;
>> typedef itk::Image<PixelType , Dimension> ImageType ;
>> typedef itk::ImageSeriesReader<ImageType> ReaderType ;
>> //there still some parameters can be set
>> typedef itk::NumericSeriesFileNames NameGeneratorType ;
>> NameGeneratorType::Pointer nameGenerator = NameGeneratorType::New();
>>
>> nameGenerator->SetSeriesFormat("C:\\Users\\zhq\\Desktop\\data\\SNAP_CR\\E403434298\\E403434298S1901I%3d.dcm");
>> nameGenerator->SetStartIndex(301);
>> nameGenerator->SetEndIndex(350);
>> nameGenerator->SetIncrementIndex(1);
>> ReaderType::Pointer reader = ReaderType::New();
>> reader->SetImageIO(itk::GDCMImageIO::New());
>> reader->SetFileNames(nameGenerator->GetFileNames());
>> reader->Update();
>> std::cout<<"reader updata"<<std::endl;
>>
>> typedef itk::Image<double,3> doubleImageType ;
>> typedef itk::ShiftScaleImageFilter<ImageType,doubleImageType> ShiftFilter
>> ;
>> ShiftFilter::Pointer filter = ShiftFilter::New();
>> filter->SetInput(reader->GetOutput());
>> filter->Update();
>> std::cout<<"filter updata"<<std::endl ;
>>
>> typedef itk::HessianRecursiveGaussianImageFilter<doubleImageType>
>> HessianFilterType;
>> HessianFilterType::Pointer hessianFilter = HessianFilterType::New();
>> hessianFilter->SetInput(filter->GetOutput());
>> hessianFilter->Update();
>> std::cout<<"hessian Filter"<<std::endl ;
>> //if read 44 files , there is a error
>> typedef itk::Hessian3DToVesselnessMeasureImageFilter<float>
>> VesselMeasureFilterType ;
>> VesselMeasureFilterType::Pointer vesselFilter =
>> VesselMeasureFilterType::New();
>> vesselFilter->SetInput(hessianFilter->GetOutput());
>> vesselFilter->Update();
>> std::cout<<"vesselFilter update"<<std::endl;
>>
>> typedef itk::ImageFileWriter< itk::Image<float,3> > WriterType ;
>> WriterType::Pointer writer = WriterType::New();
>> writer->SetInput(vesselFilter->GetOutput());
>> writer->SetFileName("C:\\Users\\zhq\\Desktop\\mydata.vtk");
>> writer->Update();
>> std::cout<<"writer updata"<<std::endl ;
>>
>> system("pause");
>> }
>>
>>
>>
>>
>>
>>
>> At 2013-08-02 11:24:29,"Matt McCormick" <matt.mccormick at kitware.com
>>
>> > wrote:
>> >Hi,
>> >
>> >Here[1] is a very simple brain vessel segmentation example.
>> >
>> >For more advanced vessel segmentation methods, you may want to try
>> >TubeTK[2], which supports analysis and visualization with the ITK and
>> >VTK based 3DSlicer[3].
>> >
>> >Thanks,
>> >Matt
>> >
>> >[1] http://itk.org/ITKExamples/src/Filtering/ImageFeature/SegmentBloodVessels/Documentation.html
>>
>> >[2] http://tubetk.org/
>> >[3] http://slicer.org/
>> >
>> >On Fri, Jul 26, 2013 at 9:19 PM, 章强 <15891495523 at 126.com> wrote:
>> >> Hello :
>> >> there is a series of dcm format files which is the results of scanning
>> >> the brain . I want to segment blood vessels from these files with ITK , and
>> >> show it with VTK . Please give me a simple case . I have a problem with
>> >> this project .
>> >> how can I segment a specified region ? I know that ITK provide some
>> >> segmentation algorithm , but they need the Index of seeds . Can I show the
>> >> picture with VTK fristly ,and then point out a seed in the picture ? And if
>> >> there are some algorithms which can segment volume data ?
>> >>
>> >>
>> >> 来自网易手机号码邮箱了解更多
>> >>
>> >> _____________________________________
>> >> 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:
>> >> http://www.itk.org/mailman/listinfo/insight-users
>> >>
>>
>>
>>
>> 来自网易手机号码邮箱了解更多 <http://shouji.163.com>
>>
>
>
>
> 来自网易手机号码邮箱了解更多 <http://shouji.163.com>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130807/47632cf6/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: image/jpeg
Size: 51023 bytes
Desc: not available
URL: <http://www.itk.org/pipermail/insight-users/attachments/20130807/47632cf6/attachment-0001.jpeg>
More information about the Insight-users
mailing list