[Insight-users] Question about thresholding

Luis Ibanez luis.ibanez@kitware.com
Fri, 15 Mar 2002 11:07:27 -0500


Hi Dhananjay,

You can use the "itkThresholdImageFilter".

http://www.itk.org/Insight/Doxygen/html/classitk_1_1ThresholdImageFilter.html#a3

you connect your image as imput, select the threshold
in the filter and got a thresholded image as output.

a 3D example will look like:

typedef   itk::Image<char, 3 >  myImageType;
myImageType::Point   inputImage = GotTheInputImageSomeHow();

typedef itk::ThresholdImageFilter <  myImageType >  myFilterType;

myFilterType::Pointer  filter = myFilterType::New();
filter->SetInput(  inputImage );  // connect the input image
filter->ThresholdAbove( 100 );
filter->SetOusideValue(  255 );  // set to 255 al the pixels above 100
filter->Update();  // run the filter.
myImageType::Pointer outputImage = filter->GetOutput();


It may look like a lot of lines just for thresholding   :-)
but keep in mind that ITK has a data pipeline desing so in
principle the rest of your processing is following and you
will write the whole set of code only once. Note that the filter is
leaving unchanged the pixels with values below 100.

There is a test program that can also help you to play with the filter
without writing a new project.  Enable "TEST" in CMake and
go to:

      Insight/Testitng/BasicFilters

the test is called :   itkThresholdImageFilterTest.cxx

Keep in mind that tests are not exactly intended to be used as
examples or as tutorials. They are designed to excersice all
the functinalities of the particular class being tested.....so you
will see a lot of code around that is there only to test that
everything is working.

Let us know if you run into any problem.


Thanks

Luis

======================================

Dhananjay Kulkarni wrote:

>Is there any method available with ITK to Threshold an image ?
>All the examples I looked at had some Filter which in turn would use the
>Threshold function.
>I am looking at one single method.
>
>Any comments and Suggestions would be greatly appreciated.
>
>Thanks,
>-danny
>
>_______________________________________________
>Insight-users mailing list
>Insight-users@public.kitware.com
>http://public.kitware.com/mailman/listinfo/insight-users
>