# ITK Vessels segmentation code

**URL:** https://discourse.itk.org/t/itk-vessels-segmentation-code/1923
**Category:** Beginner Questions
**Created:** [May 30, 2019, 4:04pm UTC](https://discourse.itk.org/t/itk-vessels-segmentation-code/1923 "2019-05-30T16:04:26Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![Pooja\_Virkar](https://discourse.itk.org/user_avatar/discourse.itk.org/pooja_virkar/32/804_2.png) [@Pooja\_Virkar](https://discourse.itk.org/u/Pooja_Virkar)
#### Post date: [May 30, 2019, 4:04pm UTC](https://discourse.itk.org/t/itk-vessels-segmentation-code/1923/1 "2019-05-30T16:04:26Z")

</div>

Hello,

1. I am trying to run Vessels segmentation program from

[https://itk.org/ITKExamples/src/Nonunit/Review/SegmentBloodVesselsWithMultiScaleHessianBasedMeasure/Documentation.html](https://itk.org/ITKExamples/src/Nonunit/Review/SegmentBloodVesselsWithMultiScaleHessianBasedMeasure/Documentation.html)

But I am getting following error -  
fatal error: itkMultiScaleHessianBasedMeasureImageFilter.h: No such file or directory

Also I am unable to understand that in this program, for Input what should I give 2D image/slice or 3D volume /series?  
And how to choose the sigma values?

1. Also I tried the program from

[https://itk.org/ITKExamples/src/Filtering/ImageFeature/SegmentBloodVessels/Documentation.html](https://itk.org/ITKExamples/src/Filtering/ImageFeature/SegmentBloodVessels/Documentation.html)

But still not getting an error -  
error:  
itk::ExceptionObject (0x1682ae0)  
Location: “void itk::RecursiveSeparableImageFilter\<TInputImage, TOutputImage\>::BeforeThreadedGenerateData() [with TInputImage = itk::Image\<float, 3\>; TOutputImage = itk::Image\<float, 3\>]”  
File: /usr/local/include/ITK-4.13/itkRecursiveSeparableImageFilter.hxx  
Line: 245  
Description: itk::ERROR: RecursiveGaussianImageFilter(0x164fc50): The number of pixels along direction 2 is less than 4. This filter requires a minimum of four pixels along the dimension to be processed.

In this program dimension is 3. So should I give series as input? And how to select sigma and alpha values for vessels segmentation?

Please help me to solve this error.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [May 30, 2019, 4:34pm UTC](https://discourse.itk.org/t/itk-vessels-segmentation-code/1923/2 "2019-05-30T16:34:22Z")

</div>

The first example uses 2D images as input, the second one uses 3D images.

> [@Pooja\_Virkar](#):
>
> fatal error: itkMultiScaleHessianBasedMeasureImageFilter.h: No such file or directory

As answered on [stack overflow](https://stackoverflow.com/a/56381931/276168), you need to set CMake variable `Module_ITKReview` to **ON** when configuring ITK.

> [@Pooja\_Virkar](#):
>
> The number of pixels along direction 2 is less than 4.

You should change `Dimension` to be 2 if you are working with 2D images. 2D images have 1 pixel along third axis.

As to choosing proper sigma values, they should be close in size to the vessels present in the image. But you will have to experiment with different sizes to find the appropriate one for your task.

---

<div class="post-metadata">

### Author: ![Pooja\_Virkar](https://discourse.itk.org/user_avatar/discourse.itk.org/pooja_virkar/32/804_2.png) [@Pooja\_Virkar](https://discourse.itk.org/u/Pooja_Virkar)
#### Post date: [May 31, 2019, 10:08am UTC](https://discourse.itk.org/t/itk-vessels-segmentation-code/1923/3 "2019-05-31T10:08:42Z")

</div>

Thank you for the help.  
Its working.

But I have one more doubt.  
For following program -

[https://itk.org/ITKExamples/src/Filtering/ImageFeature/SegmentBloodVessels/Documentation.html](https://itk.org/ITKExamples/src/Filtering/ImageFeature/SegmentBloodVessels/Documentation.html)  
strong text  
If I changed the dimension = 2 in program, then I am getting following error. (attached in pdf)[print.pdf](https://discourse.itk.org/uploads/default/original/1X/d2ef74d6e443dd5ed7b2f66348adb570dda37fa6.pdf) (18.5 KB)  
[print1.pdf](https://discourse.itk.org/uploads/default/original/1X/ba0acf339907d9e9db2b7512c7352e36e3bee168.pdf) (16.9 KB)

How to solve it? & What changes should I do in program for dimension =2 ?

And also if I want to keep the dimension = 3, then it means i should provide 3D data ie. complete series of slices. Is it correct?  
And for header file “itkImageSeriesReader” should include in program. It will work then?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [May 31, 2019, 3:57pm UTC](https://discourse.itk.org/t/itk-vessels-segmentation-code/1923/4 "2019-05-31T15:57:44Z")

</div>

The filter [Hessian3DToVesselnessMeasureImageFilter](https://itk.org/Doxygen/html/classitk_1_1Hessian3DToVesselnessMeasureImageFilter.html) is working only with 3D images, as its name implies. I guess the first example can be adjusted to work with different image dimensions, whereas the second one only works with 3D images.

> [@Pooja\_Virkar](#):
>
> keep the dimension = 3, then it means i should provide 3D data

That is correct. And you could use `itkImageSeriesReader`, or convert your series to a single-file 3D image (.mha, .nrrd etc) using e.g. [Slicer](https://slicer.org/).

---

<div class="post-metadata">

### Author: ![Pooja\_Virkar](https://discourse.itk.org/user_avatar/discourse.itk.org/pooja_virkar/32/804_2.png) [@Pooja\_Virkar](https://discourse.itk.org/u/Pooja_Virkar)
#### Post date: [June 8, 2019, 3:29pm UTC](https://discourse.itk.org/t/itk-vessels-segmentation-code/1923/5 "2019-06-08T15:29:07Z")

</div>

Hello,  
I tried this Hessian3DToVesselnessMeasureImageFilter with my dicom series. But I am getting following error.

Error: In /home/PVirkar/bin/ITK/InsightToolkit-4.13.2/Modules/ThirdParty/GDCM/src/gdcm/Source/MediaStorageAndFileFormat/gdcmPixmapWriter.cxx, line 649, function bool gdcm::PixmapWriter::PrepareWrite(const gdcm::MediaStorage&)  
Problem with NumberOfDimensions and MediaStorage

Error:  
itk::ExceptionObject (0x238bab0)  
Location: “virtual void itk::GDCMImageIO::Write(const void\*)”  
File: /home/PVirkar/bin/ITK/InsightToolkit-4.13.2/Modules/IO/GDCM/src/itkGDCMImageIO.cxx  
Line: 1232  
Description: itk::ERROR: GDCMImageIO(0x2342980): DICOM does not support this component type

I used signed short and unsigned int as pixel types (because it supports Dicom series) and dimension = 3.  
But still I don’t understand why error showing “DICOM does not support this component type”

Also I would like to get a single dicom file as output, ie i am using itkImageFileWriter.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [June 9, 2019, 4:21pm UTC](https://discourse.itk.org/t/itk-vessels-segmentation-code/1923/6 "2019-06-09T16:21:10Z")

</div>

Not all combinations of pixel types etc are valid for DICOM. Try writing into a different format, e.g. `.mha` or `.nrrd`. If that succeeds, you can then try to figure out what is the problem with DICOM.

---

<div class="post-metadata">

### Author: ![Pooja\_Virkar](https://discourse.itk.org/user_avatar/discourse.itk.org/pooja_virkar/32/804_2.png) [@Pooja\_Virkar](https://discourse.itk.org/u/Pooja_Virkar)
#### Post date: [August 30, 2019, 10:24am UTC](https://discourse.itk.org/t/itk-vessels-segmentation-code/1923/7 "2019-08-30T10:24:19Z")

</div>

Hello,

I have again tried the example mentioned on  
[https://itk.org/ITKExamples/src/Nonunit/Review/SegmentBloodVesselsWithMultiScaleHessianBasedMeasure/Documentation.html?highlight=hessian](https://itk.org/ITKExamples/src/Nonunit/Review/SegmentBloodVesselsWithMultiScaleHessianBasedMeasure/Documentation.html?highlight=hessian)

It is working with 2D DICOM image.  
But when I modified the program to work with 3D Volume (by providing series of dicom slices), i am getting following memory allocation error.

Exception thrown while writing the series

itk::MemoryAllocationError (0x7fe504000950)  
Location: “TElement\* itk::ImportImageContainer\<TElementIdentifier, TElement\>::AllocateElements(itk::ImportImageContainer\<TElementIdentifier, TElement\>::ElementIdentifier, bool) const [with TElementIdentifier = long unsigned int; TElement = itk::SymmetricSecondRankTensor\<double, 3\>; itk::ImportImageContainer\<TElementIdentifier, TElement\>::ElementIdentifier = long unsigned int]”  
File: /usr/local/include/ITK-5.0/itkImportImageContainer.hxx  
Line: 199  
Description: Failed to allocate memory for image.

What should I do to solve this error?  
thanks in advance.

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [August 30, 2019, 2:41pm UTC](https://discourse.itk.org/t/itk-vessels-segmentation-code/1923/8 "2019-08-30T14:41:13Z")

</div>

You could increase your virtual memory, or run the pipeline in a [streaming fashion](https://itk.org/ITKExamples/src/Core/Common/StreamAPipeline/Documentation.html).

---

<div class="post-metadata">

### Author: ![Pooja\_Virkar](https://discourse.itk.org/user_avatar/discourse.itk.org/pooja_virkar/32/804_2.png) [@Pooja\_Virkar](https://discourse.itk.org/u/Pooja_Virkar)
#### Post date: [September 3, 2019, 11:24am UTC](https://discourse.itk.org/t/itk-vessels-segmentation-code/1923/9 "2019-09-03T11:24:08Z")

</div>

How to run this streaming example with my vessel segmentation code?  
Sorry But i don’t understand how to use this streaming example in my code.  
And how to make pipeline using it?  
Could you provide some code for it?

---

<div class="post-metadata">

### Author: ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)
#### Post date: [September 3, 2019, 3:11pm UTC](https://discourse.itk.org/t/itk-vessels-segmentation-code/1923/10 "2019-09-03T15:11:05Z")

</div>

[Chapter 8.3](https://itk.org/ITKSoftwareGuide/html/Book1/ITKSoftwareGuide-Book1ch8.html#x54-1320008.3) in software guide has more information about it.
