[Insight-users] compute an abs. and rel. distance-field image based on a start front, an obstacle image and a finish front

Dr. Roman Grothausmann grothausmann.roman at mh-hannover.de
Mon Aug 19 06:28:19 EDT 2013


Hello Dan,


Thank You very much for Your answer. It's Your publication I got the idea from 
(as You had suggested before, I had already used it trying to compute 
center-lines in tomograms), however, if I understand it correctly, it seems that 
SpeedFunctionToPathFilter expects start points to be set. How can I specify 
start points via a binary image? Would I have to iterate over the image and for 
each fg value add its coordinates as start point?
As currently I'm not interested in "center lines" but in a kind of distance map 
would itkFastMarchingImageFilter be the right choice?

Below is my current code which compiles fine but does not yield the desired 
output (only a binary image in float format).
My guess is that SetBinaryMask is not meant for setting the start front, however 
I could not find what it is actually meant for in the docs.
I only found one example where SetBinaryMask is used but it also sets 
AlivePoints TrialPoints:
http://webcache.googleusercontent.com/search?q=cache:seDik6jwW0MJ:https://itk.icts.uiowa.edu/fisheye/browse/~raw,r%3D8cefdc7bbda0183442666f236866ba25bcda853f/ITK/Testing/Code/Algorithms/itkFastMarchingTest2.cxx+itk+FastMarchingImageFilter+%22SetBinaryMask%22&cd=7&hl=de&ct=clnk&gl=de

What do I have to do to set the start front (and if necessary the trial front) 
to consist of the border pixels of the first binary image. As it says in the 
docs: the trial points "can for instance be specified as the layer of pixels 
around the alive points". What would be the best way to do that?

Thanks for any help or hints
Roman

_____________________________________


template<typename InputPixelType, size_t Dimension>
//int DoIt(std::string ifn, std::string ofn){
int DoIt(int argc, char *argv[]){

     typedef float SpeedPixelType;
     //typedef float OutputPixelType;
     //typedef unsigned char OutputPixelType;
     //typedef unsigned int OutputPixelType;
     //typedef InputPixelType OutputPixelType;
     typedef SpeedPixelType OutputPixelType;
     //typedef TLevelSet OutputPixelType;
     // typedef float ScalarPixelType;

     // typedef itk::Image< ScalarPixelType, Dimension > LevelSetImageType;

     typedef itk::Image<InputPixelType, Dimension>  InputImageType;
     typedef itk::Image<SpeedPixelType, Dimension>  SpeedImageType;
     typedef itk::Image<OutputPixelType, Dimension>  OutputImageType;

     typedef itk::ImageFileReader<InputImageType> ReaderType;
     typename ReaderType::Pointer reader = ReaderType::New();
     typename ReaderType::Pointer reader2 = ReaderType::New();

     reader->SetFileName(argv[1]);
     FilterWatcher watcherI(reader, "reading");
     try
         {
         reader->Update();
         }
     catch (itk::ExceptionObject &ex)
         {
	if (!strcmp(ex.GetDescription(), "Filter does not have progress.")){
             std::cerr << ex << std::endl;
             //std::cerr << ex.GetDescription() << std::endl;
             return EXIT_FAILURE;
             }
         }

     reader2->SetFileName(argv[2]);
     FilterWatcher watcherI2(reader2, "reading");
     try
         {
         reader2->Update();
         }
     catch (itk::ExceptionObject &ex)
         {
	if (!strcmp(ex.GetDescription(), "Filter does not have progress.")){
             std::cerr << ex << std::endl;
             //std::cerr << ex.GetDescription() << std::endl;
             return EXIT_FAILURE;
             }
         }


     ////convert binary image to speed image, i.e. scale to [0; 1]
     typedef itk::RescaleIntensityImageFilter<InputImageType, SpeedImageType> 
RescaleType;
     typename RescaleType::Pointer rescaler = RescaleType::New();
     rescaler->SetInput(reader->GetOutput());
     rescaler->SetOutputMinimum(0);
     rescaler->SetOutputMaximum(1);
     rescaler->Update();

     ////convert binary image to speed image, i.e. scale to [0; 1]
     typedef itk::RescaleIntensityImageFilter<InputImageType, SpeedImageType> 
RescaleType;
     typename RescaleType::Pointer rescaler2 = RescaleType::New();
     rescaler2->SetInput(reader2->GetOutput());
     rescaler2->SetOutputMinimum(0);
     rescaler2->SetOutputMaximum(1);
     rescaler2->Update();


     //typedef itk::FastMarchingImageFilter<InputImageType, SpeedImageType> 
FilterType;
     typedef itk::FastMarchingImageFilter<SpeedImageType, SpeedImageType> 
FilterType;
     typename FilterType::Pointer filter = FilterType::New();
     //filter->SetBinaryMask(reader->GetOutput());//setting the start front via 
an image
     filter->SetBinaryMask(rescaler->GetOutput());//setting the start front via 
an image
     filter->SetInput(rescaler2->GetOutput());//setting the speed image

     filter->SetStoppingValue( 100.0 );


     FilterWatcher watcher(filter, "FastMarchingImageFilter");
     try {
         filter->Update();
         //std::cout << std::endl;
         }
     catch (itk::ExceptionObject &ex)
         {
         std::cout << ex << std::endl;
         return EXIT_FAILURE;
         }



     typedef itk::ImageFileWriter<OutputImageType>  WriterType;
     typename WriterType::Pointer writer = WriterType::New();

     FilterWatcher watcherO(writer, "writing");
     writer->SetFileName(argv[3]);
     writer->SetInput(filter->GetOutput());
     try
         {
         writer->Update();
         }
     catch (itk::ExceptionObject &ex)
         {
         std::cout << ex << std::endl;
         return EXIT_FAILURE;
         }




     return EXIT_SUCCESS;

     }




On 16/08/13 23:01, Dan Mueller wrote:
> Hi Roman,
>
> This can be achieved with Fast Marching: the start front image will be your
> trial points, and the obstacle image the speed function (0.0 for obstacles, 1.0
> for areas the front can expand).
>
> You may be interested in the following Insight Journal publication: Fast
> Marching Minimal Path Extraction
> http://www.insight-journal.org/browse/publication/213
>
> One of the examples shows how to extract a continuous directed path front a
> starting point and avoiding obstacles.
>
> HTH
>
> Cheers, Dan
>
> On 16 Aug 2013 22:46, "Dr. Roman Grothausmann"
> <grothausmann.roman at mh-hannover.de <mailto:grothausmann.roman at mh-hannover.de>>
> wrote:
>
>     Dear mailing list members,
>
>
>     Starting with two binary images, I want to compute a distance-field image
>       in a way that the first binary image is regarded as the start front and
>     the second binary image represents obstacles in the way of the propagation
>     front. From what I've read about similar problems either fast-marching or
>     geodesic filters can supply the output I'm looking for.
>     What itk-filter do I need for that? The
>     itkReconstructionByDilationIma__geFilter seems only to take one input image
>     although in the description a marker and a mask image are mentioned. The
>     itkFastMarchingImageFilter seems to need a speed image, can that be
>     constant, i.e. can it be the binary image containing the obstacles or would
>     I have to supply a distance-map of the obstacle image?
>
>     In a second step I'd like to normalize the absolute distance field image of
>     the previous result. For that I want to supply a third binary image. The
>     normalization should be done in a way that the abs. distance field image is
>     adjusted such that it contains relative distance, i.e. between 0 and 1. The
>     values of the abs. distance field should be adjusted such that the pixels of
>     the shortest paths from any of the pixels making up the propagation start
>     front to the finish front (contained in the third binary image) should
>     linearly increase from 0 to 1. I'm not sure if this can be done because
>     possibly the solution is not well/uniquely defined.
>     Any ideas or comments on this are very welcome.
>
>     Thanks for any help or hints
>     Roman
>
>
>
>     --
>     Dr. Roman Grothausmann
>
>     Tomographie und Digitale Bildverarbeitung
>     Tomography and Digital Image Analysis
>
>     Institut für Funktionelle und Angewandte Anatomie, OE 4120
>     Medizinische Hochschule Hannover
>     Carl-Neuberg-Str. 1
>     D-30625 Hannover
>
>     Tel. +49 511 532-9574 <tel:%2B49%20511%20532-9574>
>     _______________________________________
>     Powered by www.kitware.com <http://www.kitware.com>
>
>     Visit other Kitware open-source projects at
>     http://www.kitware.com/__opensource/opensource.html
>     <http://www.kitware.com/opensource/opensource.html>
>
>     Kitware offers ITK Training Courses, for more information visit:
>     http://www.kitware.com/__products/protraining.php
>     <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 <http://www.itk.org/Wiki/ITK_FAQ>
>
>     Follow this link to subscribe/unsubscribe:
>     http://www.itk.org/mailman/__listinfo/insight-users
>     <http://www.itk.org/mailman/listinfo/insight-users>
>

-- 
Dr. Roman Grothausmann

Tomographie und Digitale Bildverarbeitung
Tomography and Digital Image Analysis

Institut für Funktionelle und Angewandte Anatomie, OE 4120
Medizinische Hochschule Hannover
Carl-Neuberg-Str. 1
D-30625 Hannover

Tel. +49 511 532-9574


More information about the Insight-users mailing list