[Insight-users] Re: Question About Connected Threshold Filter

Luis Ibanez luis . ibanez at kitware . com
Wed, 01 Oct 2003 15:59:08 -0400


Hi Neha,

Note that because your are smoothing the image, the
intensity values of your histogram will be very
different after the smoothing.

Your pipeline probably looks like:

Reader --->  Smoothing ---> ConnectedThreshold

You should select the threholds by looking at the
histogram of the smoothed image, not the input
image.

My guess is that your seed point in the smoothed
image does not have an intensity in the range
215-254, or it does not have any neighbors in this
range.

You could easily test this hypotesis by doing:

      smoother->Update()
      std::cout <<< (int)smoother->GetOutput()->GetPixel( seedPoint );

another easy way to see what is presented to the
connected threshold filter is to use a binary threshold
image filter after the smoothing, threshold the range
215-254, and then save the resulting image. You will see
then the regions that can potentially be collected by
the connected threshold filter.

The BinaryThresholdImageFilter is described in the SoftwareGuide
http://www . itk . org/ItkSoftwareGuide . pdf
Section 6.1, pdf-page 139.



About the RescaleIntensityImageFilter, you simply don't
need it here.  You will find a description of this filter
in the SoftwareGuide
http://www . itk . org/ItkSoftwareGuide . pdf
Section 6.2 "Casting and intensity mapping", pdf-page 146.



Regards,


    Luis


------------------------
Neha D wrote:
> Hi Luis,
>  
> Thanks for the reply. Actually, I use those threshol values only once 
> (after they are read from user, they are not changes)
> Now, the problem is -> output image contains only the seed point 
> (probably). I am sending my input image ( whose pixels are within range 
> 215-254 if we look at the histogram)
> I select the seed index as (304, 170).
> Now, if i specify lower and upper thresholds as (215 and 254 
> respectively ), I expect many pixels to be included in the o/p image ( 
> setReplace value - 255 ) 
> But this is not happening. I see only one point in the o/p image.
>  
> Can you please tell me why is o/p image like this? Also, can you please 
> tell me when I am supposed to use RescaleIntensityImageFilter?
>  
> Here is the code i am using -->
> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>   connectedThreshold->SetInput( smoothingFilter->GetOutput() );
>    to_short->SetInput( connectedThreshold->GetOutput() );
>    writer->SetInput( to_short->GetOutput() );       
>    
>    std::cout<<"\n Enter value for No. Of Iterations: (around 10 is a 
> good value) \n";
>    std::cin>>noOfIterations;
>    
>    smoothingFilter->SetNumberOfIterations(noOfIterations);
>    smoothingFilter->SetTimeStep( 0.125 );    
>     
>    std::cout<<"\n Enter value for Lower Threshold: \n";
>    std::cin>>lowerThreshold;
>    std::cout<<"\n Enter value for Upper Threshold: \n";
>    std::cin>>upperThreshold;
>    
>    connectedThreshold->SetLower( (const float)lowerThreshold );
>    connectedThreshold->SetUpper( (const float)upperThreshold );
>    connectedThreshold->SetReplaceValue( 255 );
>    
>    // Take User input for Seed Index
>    std::cout<<"\n Enter X value for Seed: \n";
>    std::cin>>seedX;
>    std::cout<<"\n Enter Y value for Seed: \n";
>    std::cin>>seedY;
>    seedIndex[0] = seedX; // first index on X
>    seedIndex[1] = seedY; // first index on Y
>    
>    connectedThreshold->SetSeed( seedIndex );   
>  
> /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
>  
> Thanks,
>  
> Neha
> 
> */Luis Ibanez <luis . ibanez at kitware . com>/* wrote:
> 
> 
>     Hi Neha,
> 
>     I'm assuming that you are making reference to the example
> 
>     ConnectedThresholdImageFilter.cxx
> 
>     in the directory
> 
>     Insight/Examples/Segmentation
> 
>     and to the lines 221-221:
> 
>      >
>      > const InternalPixelType lowerThreshold = atof( argv[5] );
>      > const InternalPixelType upperThreshold = atof( argv[6] );
>      >
> 
>     If that's the case, The answer to your question:
> 
>     "Why is it made constant ? "
>     is:
> 
>     "Because these values are not expected to change"
> 
> 
>     In this example, the threshold values are read from the command
>     line arguments and used for setting the parameters of the filter.
>     The filter is run once, and then we quit the application. In this
>     circumstances, there is no reason for changing the threshold values,
>     and henceforth they should be declared 'const'.
> 
>     You are not forced to d! o so, but it is a healthy practice. It sets the
>     compiler on your side, since it will help you to detect undesired
>     attempts for modifiying the value of these variables.
> 
> 
>     Now that,.... if you are introducing changes in this code for reusing
>     the filter and runing with several different values of the threshold,
>     then.... your values are now expected to change and you are fully
>     entitled to discard the "const" qualifier.
> 
>     ITK is enforcing const-correctess as a modern C++ practice.
>     You will find the usage of "const" in many places on the toolkit.
> 
> 
>     Regards,
> 
> 
>     Luis
> 
> 
>     -------------------
>     Neha D wrote:
> 
>      > Hi All,
>      >
>      > I am trying to use ConenctedThreshold Filter to check on Breast
>     MRIs.
>      > For that i want to use different upper and lower threshold
>     values. But
>      > since they are made of "const float" i can not use them dynamically.
>      > Would like to know why is it made constant.
>      >
>      > Thanks,
>      >
>      > Neha
>      >
>      >
>      >
>      >
>      >
>      >
>     ------------------------------------------------------------------------
>      > Do you Yahoo!?
>      > Yahoo! SiteBuilder
>      > -
>      > Free, easy-to-use web site design software
> 
> 
> 
> 
> ------------------------------------------------------------------------
> Do you Yahoo!?
> Yahoo! SiteBuilder 
> <http://us . rd . yahoo . com/evt=10469/*http://sitebuilder . yahoo . com> - Free, 
> easy-to-use web site design software