[Insight-users] watershedImage filter
Luis Ibanez
luis . ibanez at kitware . com
Thu, 12 Jun 2003 09:42:45 -0400
Hi Chandu,
1) Is your input image actually a multicomponent image ?
e.g. RGB,
The VectorGradientAnisotropicDiffusion is intended for
multicomponent data.
If you data is not multicomponent, you can save a lot
of time by just using the scalar version, the filter:
GradientAnisotropicDiffusionImage
2) How big is your image ?
Depending on the size of your image, 7 minutes may or may
not be a reasonable time.
3) Are you compiling for Release ?
This may a huge difference in ITK since when you use
optimization, many templated functions got inlined.
That's after all one of the major reasons for writing
ITK as a templated library. Most filters will run
twice as fast after you compile them for release.
4) The concepts of Threshold and Level are explained in the
SoftwareGuide.
http://www . itk . org/ItkSoftwareGuide . pdf
Section 8.2, pdf-page 262.
Both of them are measured as percentage of the maximum
value of the input image to the watershed filter.
Note that the input image to the watershed filter is
usually the gradient magnitude of your image.
It is a good practice to preprocess your original image
by doing:
a - anisotropic diffusion filter, then
b - GradientMagnitudeRecursiveGaussian
and save the result in a file.
Then study this image in order to get an idea of intensity
(of the gradient magnitude) int the borders of the object
you want to segment. Imagine your object as a lake, and the
gradient magnitude images as the mountains surrounding your
lake. What the watershed filter does is to start filling
the lake with water. As the water level goes up, it will
leak through the lowest passage in the mountains surrounding
the lake.
So, you want to identify the lowest passage of those mountains,
Take the intensity of the gradient magnitude there, then compute
the ratio between this intensity and the maximum intensity of
the gradient magnitude in the whole image. This will give you
a number in the range [0:1], That's the number you want to
provide as "LEVEL" parameter to the watershed filter. Actually
this number minus an "epsilon", since you want to make sure that
the water will not overflow from the lake.
5)The Threshold parameter is a mechanism for avoiding wasting
computing time (and memory) in all the micro lakes in the image.
What it does is start the water filling at a minimum level of
water. This is closely related to the noise level of the input
image. In practice you are safe by using any Threshold value
that is lower than your LEVEL. As a rule of thumb you could
put the Threshold value to the 1/10 of the water level.
6) There is an example on the use of watershed, associated with
the text in the software guide. You will find this example in
Insight/Examples/Segmentation/Watershedsegmentation1.cxx
You are encouraged to play with the parameters of this example,
on the standard images provided in Insight/Examples/Data.
Try to make sure that you get a feeling on the effect of each
parameter before you move to use it in your own data.
7) As an advice:
Separate the pre-processing from the actual execution of the
watershed filter. The watershed is actually pretty fast.
In practice the preprocessing will take most of the time.
The watershed results will be as good (or as bad) as your
gradient magnitude image is.
Please group the pipeline:
GradientAnisotropicDiff + GradientMagnitudeRecursiveGaussian
in a separate program, run it in your data, and tune the parameters
until you get a neat image with clear borders around the region to
be segmented. Once you get this image, it should be pretty
straight forward to use the watershed filter for extracting the
regions.
Regards,
Luis
--------------------------
cspl wrote:
> Hi !!
> I am using itkWatershedImageFilter in my application.Iam giving the
> standard input to the itkVectorGradientAnisotropicDiffusionImageFilter
> parameters as no.of iterations=10 ,conductance parameter=2.0 and
> timestep=0.125.Iam using the 2D images.Iam getting the output,but it is
> taking longtime(7min to 30min) to get the output based on the image.I
> couldn't understand the Level ,threshold ,flood level clearly.Is there
> any solution to increse the speed of the appliction.
>
> Thanking You,
> Chandu.