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

Mathieu Malaterre Mathieu.Malaterre@creatis.insa-lyon.fr
Wed, 19 Feb 2003 19:00:27 +0100


Luis,

    Thank you for your answer.
    I'll try to be more precise.

    So far I only get a portion of my image (black and white but 
dimensions are smaller in 'y' direction).

original image:
DIMENSIONS 59 144 79

output of threshold:
DIMENSIONS 59 31 79

   What I want to know is if I used properly the region iterator of an 
image. In my image the contrast agent is very bright in the aneursim 
(and a little bit more gray in the vessel end .. which all my problem).

If you want you can have a look at a slice:
http://www.creatis.insa-lyon.fr/~malaterre/vtk/vessel.png

You'll -hardly- see a cross that shows the value at selected pixel : 107.875

If I use ConnectedThresholdImageFilter with a Lower thershold of 107.875 
and an Upper threshold of 10000 I got some noise around my vessel, which 
of course I don't want.

If now you look carefully at this image, you'll see that the end of the 
vessel (where the selected pixel is) is surrounded by a very dark 
background. The idea that came was to cut this image into pieces and 
threshold it with different Lower values (upper value doesn't matter). 
For instance we can divide this image (vessel.png) into 4 pieces:


----------------------------
|     |      |      |      |
|     |      |      |      |
|     |      |      |      |
|     |      |      |      |
----------------------------

   L1     L2     L3     L4

Where L_i is the Lower threshold value associated with each pieces of 
image (with L1 <> L2 <> L3 <> L4). This is just as if I wanted to 
threshold a part of the image without knowing it is part of a bigger one.


Hopping to be clear this time, do not hesitate to ask me if I wasn't.

thanks a lot for time Luis,

Mathieu


Luis Ibanez wrote:
> 
> 
> Hi Matheiu,
> 
> 
> Could you please be more specific with your
> statement that the process:
> 
>          "Doesn't work"
> 
> Do you mean:
> 
> 1) doesn't compile ?
> 2) seg. faults ?
> 3) throws exceptions ?
> 4) produces a corrupted output image ?
> 5) produces a black image ?
> 6) ...?
> 
> 
> ----
> 
> 
>  From your code example is not quite clear what you
> want to do with the ConnectedThresholdImageFilter.
> 
> This filter applies a region growing algorithm.
> 
> It starts from your seed, and add connected pixels
> under the rule that their intensities must be
> inside the interval  defined by [lower,upper]
> threshold.
> 
> The output of this filter is a binary image.
> 
> The filter is described in detail on the
> SoftwareGuide.pdf
> 
> http://www.itk.org/ItkSoftwareGuide.pdf
> 
> Section 8.1.1, pdf pages 245-248.
> 
> You are not defining the Upper threshold in
> your code...
> 
> 
> ---
> 
> 
> I'm guessing that this is not the filter you are
> intending to use here. Probably what you want is
> a simple thresholder.  If this is the case, you
> may want to look at the
> 
>      BinaryThresholdImageFilter
> 
> Described in the SoftwareGuide:
> 
> 
> Section 5.1, pdf-pages 89-91.
> 
> 
> This is a more typical pixe-wise thresholding filter.
> 
> Note that the output image is a binary image, for
> which you have to provide the value to be used
> inside and the value to be used outside.
> 
> Again, this is explained in detail in the SoftwareGuide.
> Examples for these two filters are available under
> 
> Insight/Examples/Filtering/BinaryThresholdImageFilter.cxx
> 
>    and
> 
> Insight/Examples/Segmentation/ConnectedThresholdImageFilter.cxx
> 
> 
> 
> Please let us know if your have further questions
> after reading these sections of the SoftwareGuide.
> 
> 
> 
>    Thanks
> 
> 
> 
>      Luis
> 
> 
> 
> BTW, if what you want to do is vessel segmentation,
> you may find interesting the example of Curve2DExtraction
> which is designed to extract the medial lines of vessels
> from fluoroscopic images.
> 
> 
>     http://www.itk.org/HTML/Curve2DExtraction.htm
> 
> 
> 
> 
> 
> 
> 
> 
> ================================================
> 
> 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
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users@public.kitware.com
> http://public.kitware.com/mailman/listinfo/insight-users
> 


-- 
Mathieu Malaterre
CREATIS
28 Avenue du Doyen LEPINE
B.P. Lyon-Montchat
69394 Lyon Cedex 03
http://www.creatis.insa-lyon.fr/~malaterre/