[Insight-users] filter to create a subgraph of an image

Richard Beare richard.beare at gmail.com
Thu May 27 05:49:29 EDT 2010


Hi,

You can apply flat or non flat structuring elements to greyscale
images. The standard ITK morphology filters use flat structuring
elements, including the consolidated morphology tools that implement
accelerated versions of many of them.

The BinaryBallStructuring element used in many of the examples is a
flat structuring element. In 2d it is a binary disc, in 3d it is a
binary sphere. In the case of a rolling ball for a 2d image the
structuring element would be a greyscale disc, with the cross section
of the greyscale (i.e. the profile) being elliptical. As far as I know
there isn't an implementation of this in ITK. The parabolic morphology
package I wrote is another example of non flat structuring elements.

The difficulty with all the non flat structuring elements is that you
need to decide on a vertical size of the structuring element. This
vertical size relates to the image intensity, so its behaviour becomes
dependent on the intensity scaling which isn't the case for the flat
structuring elements.

The imagej rolling ball code uses a number of tricks to achieve good
performance - it subsamples the image first, and it may also use the
line based decomposition of Adams (matlab also uses this) to increase
efficiency.

The simplest way to think about the rolling ball filter used in imagej
(which is a morphological opening by a ball) for background intensity
estimation, is to think about the grayscale image as a surface or
landscape. The opening operation is pushing a ball upwards into the
surface and everywhere the ball doesn't touch the surface is removed
and replaced by the top of the ball at that point. This is exactly the
same as the operation with the parabola depicted in the paper attached
to the code I wrote. It is also the same operation as a flat
structuring element - except in the latter case we are pushing a flat
disc (or square or any other shape) into the surface.

So what difference does it make? Lets consider a flat, horizontal
surface, with a cylinder sticking out of it - i.e a bright circle on a
darker background. If we open by a rolling ball operation where the
ball diameter is larger than the circle then well end up with a part
of a sphere sticking up from the flat surface. If we open by a
parabola then there will be a parabolic bulge in the surface. In both
cases we are assuming the greyscale dimension of the se is such that
the bright circle is above the top of the sphere when the sphere is
pushed into the hole from below. However if we open by a flat
structuring element then the resulting surface will be completely
flat.

Of course practical surfaces, such as protein gel images which were
one of the early applications of this technique, aren't flat, so
results often appear to have fewer harsh artifacts if something like a
sphere is used.

I don't know what your application is, but my suggestion would be to
see how far you get with flat structuring elements (start with
rectangles and move up in complexity). These have been optimized to
run pretty fast and independently of kernel size. If this doesn't do
the job then try the parabolic stuff, it should be pretty similar to
rolling balls and is quite efficient. If neither of these work then
you might need to write something from scratch. Also consider
attribute filtering which can work wonders.

On Thu, May 27, 2010 at 7:16 PM, Roman Grothausmann
<roman.grothausmann at helmholtz-berlin.de> wrote:
> Many thanks Luis for Your answer.
>
> I read in P. Soille's book (p. 67,68) that You can use nonflat structuring
> elements for grey-scale images. If I'm not mistaken this is the same as the
> rolling ball filter of imagej if You have a 2D grey image and open or close
> it with a 3D ball.
>
> Richard Beare has submitted a great suite of parabolic morphology tools to
> the insight journal: http://www.insight-journal.org/browse/publication/228
> If I got it right these are nonflat structuring elements as well. Parabolas
> can only work nonflat because they are infinite in size.
>
> I would need a rolling hyper sphere/ball to filter a 3D grey image.
> Therefore I tried the GrayscaleMorphologicalClosingImageFilter but it does
> not compile if the Kernel is a BinaryBallStructuringElement<InputPixelType,
> Dimension + 1>
> So I guess I need to create this subgraph binary image of Dimension + 1 to
> be able to use a closing filter with a ball of Dimension + 1 and after that
> I have to convert it back to a grey image.
> Or is there a Opening/Closing filter that can take a SE of img-dim + 1
> already in ITK?
>
> Many thanks for any help or hints.
> Roman
>
> Luis Ibanez wrote:
>>
>> Hi Roman,
>>
>>
>> 1) If you are doing this for visualization purposes, you could look at
>>    the VTK class
>>
>> http://www.vtk.org/doc/nightly/html/classvtkImageDataGeometryFilter.html
>>
>> and the example:
>> http://www.vtk.org/Wiki/VTK/Examples/ImageData/ImageDataGeometryFilter
>>
>>
>>
>> 2) If you really want to get a 3D volume where the lines along Z
>>    are filled up, up to the value of the intensities provided by
>>    a 2D image, then you could do this by using ImageIterators.
>>
>>
>>   In particular,
>>
>>     a) Create the 3D volume from scratch (as shown in the
>>         ITK Software Guide)
>>         making sure that the X,Y dimensions match those of
>>         your input 2D image.
>>
>>     b) create a Linear iterator
>>
>> http://public.kitware.com/Insight/Doxygen/html/classitk_1_1ImageLinearIteratorWithIndex.html
>>          to visit the 3D image, and set the direction to "2" (the Z axis).
>>
>>          See the ITK Software Guide chapter on "Image Iterators"
>>
>>          at every pass of the line, get the X,Y index coordinates
>>          in order to get the pixel value from the 2D image.
>>
>>
>>
>>    Regards,
>>
>>
>>           Luis
>>
>>
>>
>> --------------------------------------------------------------------------------------
>> On Tue, May 25, 2010 at 12:07 PM, Roman Grothausmann
>> <roman.grothausmann at helmholtz-berlin.de> wrote:
>>>
>>> Dear mailing list members,
>>>
>>>
>>> Now I figured out that what I want is called a subgraph of an image. (As
>>> described on p. 19,20 by P. Soille in Morphological Image Analysis)
>>>
>>> Is there a filter in itk that creates a subgraph of a grey input image?
>>> (The only thing I could find for itk+subgraph is a bug-report:
>>>
>>> http://www.itk.org/Bug/bug_relationship_graph.php?bug_id=8005&graph=dependency)
>>>
>>> Any help is very much appreciated
>>> Roman
>>>
>>> Roman Grothausmann wrote:
>>>>
>>>> Dear mailing list members,
>>>>
>>>>
>>>> Is there a filter in ITK that converts a grey image into a profile plot
>>>> binary image? Eg a 2D grey image into a 3D binary image where the hight
>>>> of
>>>> each voxel column corresponds to the grey value of the corresponding
>>>> pixel
>>>> in the 2D image?
>>>> Or how can I apply a morphological closing/opening on the profile of an
>>>> image as described below?
>>>>
>>>> Any help is very much appreciated
>>>> Roman
>>>>
>>>> Roman Grothausmann wrote:
>>>>>
>>>>> Dear Richard,
>>>>>
>>>>> Richard Beare wrote:
>>>>>>
>>>>>> I've submitted a suite of parabolic morphology tools to the insight
>>>>>> journal :
>>>>>>
>>>>>> http://hdl.handle.net/1926/1370
>>>>>
>>>>> I get redirected to http://ij.itk.org/midas/item/view/2280 and then it
>>>>> says:
>>>>> You cannot access this item!
>>>>>
>>>>> But I found it over the Insight Journal search:
>>>>> http://www.insight-journal.org/browse/publication/228
>>>>>
>>>>> It seems to be exactly what I'm looking for but reading Your
>>>>> contribution
>>>>> article I started to wonder:
>>>>> How do You get from a 1D image (as in figure 1) to a 2D binary image
>>>>> (which consists of foreground pixel columns whose heights correspond to
>>>>> the
>>>>> intensity values of the 1D image pixels) so that You can perform the
>>>>> (2D)
>>>>> parabolic dilation?
>>>>>
>>>>> Or asked differently:
>>>>> For smoothing a 2D image a 3D-ball (or paraboloid) is rolled over the
>>>>> intensity profile which is a uneven 2D surface in 3D space. But if I
>>>>> look at
>>>>> GrayscaleDilateImageFilter it expects a structuring element in 2D if
>>>>> the
>>>>> input is a 2D image. (And I'd say it's not the same result as rolling a
>>>>> 3D-ball over the intensity profile.)
>>>>> So is there a pre-filter that would crate a 3D binary image (from my 2D
>>>>> grey image) on which I could apply the BinaryDilateImageFilter with a
>>>>> ball
>>>>> structuring element? (And then a filter to convert this 3D binary image
>>>>> back
>>>>> to a 2D grey image?)
>>>>>
>>>>> Many thanks again.
>>>>> Roman
>>>>>
>>>>>
>>>>>
>>>>>> be sure to fetch the latest version from the repository referenced in
>>>>>> the paper.
>>>>>>
>>>>>> On 4/22/10, Roman Grothausmann
>>>>>> <roman.grothausmann at helmholtz-berlin.de>
>>>>>> wrote:
>>>>>>>
>>>>>>> Dear mailing list members,
>>>>>>>
>>>>>>>
>>>>>>> To prevent a gradient decent filter from stopping at an insignificant
>>>>>>> local minimum I'd like a ball of some radius to roll over the
>>>>>>> intensity
>>>>>>> profile of an image. The result I'm interested in is the trace of the
>>>>>>> ball (or paraboloid) centre while the ball is rolling.
>>>>>>> I think this is equivalent to smoothing the image with such a rolling
>>>>>>> ball filter as this ImageJ filter:
>>>>>>>
>>>>>>> http://rsbweb.nih.gov/ij/docs/menus/process.html#background
>>>>>>>
>>>>>>> And then tracing the gradient decent as is done in the Random access
>>>>>>> iteration example in the user guide.
>>>>>>>
>>>>>>> So I wonder now is there a filter in ITK for image smoothing that
>>>>>>> works
>>>>>>> by simulating a sliding ball or paraboloid like the imageJ filter?
>>>>>>>
>>>>>>> Any help is very much appreciated
>>>>>>> Roman
>>>>>>>
>
>
> --
> Roman Grothausmann
>
> Helmholtz-Zentrum Berlin für Materialien und Energie GmbH
> Bereich Funktionale Materialien
> Institut für angewandte Materialforschung
> Hahn-Meitner-Platz 1
> D-14109 Berlin
>
> Tel.: +49-(0)30-8062-2816
> Fax.: +49-(0)30-8062-3059
>
> Vorsitzender des Aufsichtsrats: Prof. Dr. Dr. h.c. mult. Joachim Treusch
> Stellvertretende Vorsitzende: Dr. Beatrix Vierkorn-Rudolph
> Geschäftsführer: Prof. Dr. Anke Rita Kaysser-Pyzalla, Prof. Dr. Dr. h.c.
> Wolfgang Eberhardt, Dr. Ulrich Breuer
> Sitz der Gesellschaft: Berlin
> Handelsregister: AG Charlottenburg, 89 HRB 5583
>
>


More information about the Insight-users mailing list