[Insight-users] draft of adaptative threshold (itkConnectedThresholdImageFilter)

Mathieu Malaterre malat@free.fr
Wed, 19 Feb 2003 16:11:18 +0100


Hi all,

  Before starting to write a new algorithm for adaptative threshold.  I 
tried first to validate it with already existing filters.
  So here is the way I tried.

    First the user select a certain number of points *inside* the vessel 
(30 for example). And then I try to threshold the whole
   image but region by region. I work 3 points at a time, the first one 
is the left boundary,  the second one the seed for the
   threshold filter and the third one is the right boundary (the second 
point is of course between the first one and the third one).

  As there is an intensity associated to each point (and I am sure it's 
inside the vessel) I can give more accurate value for
  the threshold algorithm (compared to a global intensity value for the 
whole image, I have here a local value for each region).

  So here is a part of my algorithm that doesn't work:


    //begining of code   
    typedef itk::ExtractImageFilter<InternalImageType, 
InternalImageType> ImageExtracter;
    ImageExtracter::Pointer extracter = ImageExtracter::New();
    typedef itk::ConnectedThresholdImageFilter<InternalImageType, 
InternalImageType> ThresholdFilter;
    ThresholdFilter::Pointer threshold = ThresholdFilter::New();

    extracter->SetInput(.....);    //come from file reading
    threshold->SetInput(extracter->GetOutput());

    IndexType start;
    IndexType seed;
    SizeType  size;

    for(int i=0; i<numPoints; i+=2) {
        RegionType region;
      
        start[0] =  ...  //this is one of the user selected points
        start[1] =  ...  //...
        start[2] =  ...
        
        size[0] = ...
        size[1] = ...
        size[2] = ...
        
        seed[0] = ...
        seed[1] = ...
        seed[2] = ...
        
        region.SetIndex( start );
        region.SetSize( size );

        extracter->SetExtractionRegion( region );

        threshold->SetSeed( seed );
        threshold->SetLower(....);   //intensity at seed * coefficient

        //threshold->Modified();   //doesn't make any difference
        threshold->Update();
    }

   //end of code, where I would like to save threshold->GetOutput()


How can I force the pipeline to update the threshold filter at each loop.
If I am doing it the wrong way, could you please tell me what is the 
right way to do it.

Thank you,
mathieu