constrained and dimensionality-independent path openings

9
IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 19, NO. 6, JUNE 2010 1587 Constrained and Dimensionality-Independent Path Openings Cris L. Luengo Hendriks, Member, IEEE Abstract—Path openings and closings are morphological opera- tions with flexible line segments as structuring elements. These line segments have the ability to adapt to local image structures, and can be used to detect lines that are not perfectly straight. They also are a convenient and efficient alternative to straight line segments as structuring elements when the exact orientation of lines in the image is not known. These path operations are defined by an ad- jacency relation, which typically allows for lines that are approxi- mately horizontal, vertical or diagonal. However, because this defi- nition allows zig-zag lines, diagonal paths can be much shorter than the corresponding horizontal or vertical paths. This undoubtedly causes problems when attempting to use path operations for length measurements. This paper 1) introduces a dimensionality-indepen- dent implementation of the path opening and closing algorithm by Appleton and Talbot, 2) proposes a constraint on the path opera- tions to improve their ability to perform length measurements, and 3) shows how to use path openings and closings in a granulometry to obtain the length distribution of elongated structures directly from a gray-value image, without a need for binarizing the image and identifying individual objects. Index Terms—Granulometry, image analysis, length distribu- tion, line segment, mathematical morphology, path closing, path opening. I. INTRODUCTION P ATH openings and closings are morphological operations whose structuring elements are flexible line segments. These line segments have a general orientation, but due to their flexibility they can rotate and bend to adapt to local image structures. Path openings and closings were first proposed by Buckley and Talbot [1], and received a more thorough theoret- ical foundation by Heijmans et al. [2], [3]. A path opening of length is equivalent to the supremum of all openings with structuring elements composed of connected pixels arranged according to a specific adjacency relation. In 2-D, there are four simple adjacency relations: one that produces approximately horizontal lines, one that produces approximately vertical lines, and two that produce approximately diagonal lines. The horizontal path is formed by adding pixels either horizontally or diagonally, but always to the right [North-East (NE), East Manuscript received August 26, 2009; revised January 23, 2010. First pub- lished March 08, 2010; current version published May 14, 2010. The associate editor coordinating the review of this manuscript and approving it for publica- tion was Prof. Dan Schonfeld. The author is with the Centre for Image Analysis, Swedish University of Agri- cultural Sciences, Uppsala, Sweden (e-mail: [email protected]). Color versions of one or more of the figures in this paper are available online at http://ieeexplore.ieee.org. Digital Object Identifier 10.1109/TIP.2010.2044959 (E) and South-East (SE) neighbors]. The vertical path is formed using the North-West (NW), North (N) and NE neighbors, and the diagonal paths using either the N, NE and E or the E, SE and South (S) neighbors. Fig. 1 shows the horizontal path connectivity diagram and some example horizontal paths. Obviously, computing the opening with each of the possible connected path structuring elements of length is prohibitive even for small values of , since there are such paths. Buckley and Talbot [1] proposed a recursive algorithm to com- pute path openings that is (with the number of pixels in the image), and needs temporary images. Later, Ap- pleton and Talbot [4], [5] proposed a more efficient algorithm that seems to be , and only requires three tempo- rary images. Both algorithms are explicitly defined for 2-D im- ages. Section II proposes a simplification to the Appleton and Talbot algorithm, which allows for a definition that is indepen- dent of image dimensionality. A granulometry is a standard tool in mathematical mor- phology that builds a size distribution of objects in an image by applying an opening (or closing) of increasing size, and summing all pixel values after each step [6], [7]. In previous work [8], we have shown how a supremum of openings (or an infimum of closings) with line structuring elements at all ori- entations can be used in a granulometry to measure the length of objects in the image without segmenting the image first. Because the number of orientations needed increases linearly with the line length in 2-D [9], this can be a time-consuming operation in a 2-D image. But it becomes prohibitive in 3-D, where the number of orientations needed depends quadratically on the length. It is, therefore, attractive to use path openings instead. In 2-D, there are only four orientations over which to compute the path opening, independent of path length. In 3-D, there are 13 possible orientations. Using Appleton and Talbot’s algorithm, the operation’s cost grows logarithmically with length, for any number of dimensions. Two-dimensional path openings have recently been used in a similar manner to detect roads in satellite images [10]. There is, however, one caveat when using path openings: as will be shown, diagonal paths can zig-zag (e.g., N, E, N, E, N, etc. instead of NE, NE, NE, NE, NE, etc. ), resulting in a path that is physically much shorter than expected given the pixel count. Section III shows how to avoid this. The constraint intro- duced in that section also narrows the possible orientations for one path, making it more selective. This constraint is similar to that proposed by Buckley and Yang [11] for shortest path ex- traction, though implemented in a very different manner. Section IV-D shows how the methods proposed in this paper can be applied to estimate the length of wood fibers in a 3-D mi- crotomographic image, without the need to identify individual 1057-7149/$26.00 © 2010 IEEE

Upload: cris-l

Post on 13-Mar-2017

213 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Constrained and Dimensionality-Independent Path Openings

IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 19, NO. 6, JUNE 2010 1587

Constrained and Dimensionality-IndependentPath Openings

Cris L. Luengo Hendriks, Member, IEEE

Abstract—Path openings and closings are morphological opera-tions with flexible line segments as structuring elements. These linesegments have the ability to adapt to local image structures, andcan be used to detect lines that are not perfectly straight. They alsoare a convenient and efficient alternative to straight line segmentsas structuring elements when the exact orientation of lines in theimage is not known. These path operations are defined by an ad-jacency relation, which typically allows for lines that are approxi-mately horizontal, vertical or diagonal. However, because this defi-nition allows zig-zag lines, diagonal paths can be much shorter thanthe corresponding horizontal or vertical paths. This undoubtedlycauses problems when attempting to use path operations for lengthmeasurements. This paper 1) introduces a dimensionality-indepen-dent implementation of the path opening and closing algorithm byAppleton and Talbot, 2) proposes a constraint on the path opera-tions to improve their ability to perform length measurements, and3) shows how to use path openings and closings in a granulometryto obtain the length distribution of elongated structures directlyfrom a gray-value image, without a need for binarizing the imageand identifying individual objects.

Index Terms—Granulometry, image analysis, length distribu-tion, line segment, mathematical morphology, path closing, pathopening.

I. INTRODUCTION

P ATH openings and closings are morphological operationswhose structuring elements are flexible line segments.

These line segments have a general orientation, but due to theirflexibility they can rotate and bend to adapt to local imagestructures. Path openings and closings were first proposed byBuckley and Talbot [1], and received a more thorough theoret-ical foundation by Heijmans et al. [2], [3]. A path opening oflength is equivalent to the supremum of all openings withstructuring elements composed of connected pixels arrangedaccording to a specific adjacency relation. In 2-D, there are foursimple adjacency relations: one that produces approximatelyhorizontal lines, one that produces approximately verticallines, and two that produce approximately diagonal lines. Thehorizontal path is formed by adding pixels either horizontallyor diagonally, but always to the right [North-East (NE), East

Manuscript received August 26, 2009; revised January 23, 2010. First pub-lished March 08, 2010; current version published May 14, 2010. The associateeditor coordinating the review of this manuscript and approving it for publica-tion was Prof. Dan Schonfeld.

The author is with the Centre for Image Analysis, Swedish University of Agri-cultural Sciences, Uppsala, Sweden (e-mail: [email protected]).

Color versions of one or more of the figures in this paper are available onlineat http://ieeexplore.ieee.org.

Digital Object Identifier 10.1109/TIP.2010.2044959

(E) and South-East (SE) neighbors]. The vertical path is formedusing the North-West (NW), North (N) and NE neighbors,and the diagonal paths using either the N, NE and E or the E,SE and South (S) neighbors. Fig. 1 shows the horizontal pathconnectivity diagram and some example horizontal paths.

Obviously, computing the opening with each of the possibleconnected path structuring elements of length is prohibitiveeven for small values of , since there are such paths.Buckley and Talbot [1] proposed a recursive algorithm to com-pute path openings that is (with the number of pixelsin the image), and needs temporary images. Later, Ap-pleton and Talbot [4], [5] proposed a more efficient algorithmthat seems to be , and only requires three tempo-rary images. Both algorithms are explicitly defined for 2-D im-ages. Section II proposes a simplification to the Appleton andTalbot algorithm, which allows for a definition that is indepen-dent of image dimensionality.

A granulometry is a standard tool in mathematical mor-phology that builds a size distribution of objects in an imageby applying an opening (or closing) of increasing size, andsumming all pixel values after each step [6], [7]. In previouswork [8], we have shown how a supremum of openings (or aninfimum of closings) with line structuring elements at all ori-entations can be used in a granulometry to measure the lengthof objects in the image without segmenting the image first.Because the number of orientations needed increases linearlywith the line length in 2-D [9], this can be a time-consumingoperation in a 2-D image. But it becomes prohibitive in 3-D,where the number of orientations needed depends quadraticallyon the length. It is, therefore, attractive to use path openingsinstead. In 2-D, there are only four orientations over whichto compute the path opening, independent of path length. In3-D, there are 13 possible orientations. Using Appleton andTalbot’s algorithm, the operation’s cost grows logarithmicallywith length, for any number of dimensions. Two-dimensionalpath openings have recently been used in a similar manner todetect roads in satellite images [10].

There is, however, one caveat when using path openings: aswill be shown, diagonal paths can zig-zag (e.g., N, E, N, E, N,etc. instead of NE, NE, NE, NE, NE, etc. ), resulting in a paththat is physically much shorter than expected given the pixelcount. Section III shows how to avoid this. The constraint intro-duced in that section also narrows the possible orientations forone path, making it more selective. This constraint is similar tothat proposed by Buckley and Yang [11] for shortest path ex-traction, though implemented in a very different manner.

Section IV-D shows how the methods proposed in this papercan be applied to estimate the length of wood fibers in a 3-D mi-crotomographic image, without the need to identify individual

1057-7149/$26.00 © 2010 IEEE

Page 2: Constrained and Dimensionality-Independent Path Openings

1588 IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 19, NO. 6, JUNE 2010

Fig. 1. (a) Graph containing all possible 4-pixel horizontal paths that go through pixel �. To compute the 4-pixel path opening, one would compute the minimumvalue over each path (104 combinations) and use the maximum of these values. (b) Three possible horizontal paths with 7 pixels.

fibers through complex segmentation routines. Other parts ofSection IV highlight other possible uses of the path opening op-eration.

The source code for the path openings as proposed in thispaper, together with the scripts used to generate all the resultspresented, are available on line at http://www.cb.uu.se/ ~cris/pathopenings.html. All tests were done in MATLAB (The Math-Works, Inc., Natick, MA) using the DIPimage toolbox (http://www.diplib.org/). Path opening algorithms were implementedin C.

II. -DIMENSIONAL PATH OPENINGS

This section describes the modifications to the published al-gorithm to make it dimensionality independent. First, we willgive a short description of the algorithm as presented by Ap-pleton and Talbot [4], [5]. This section ends with some imple-mentation details.

A. Appleton and Talbot’s Path Opening Algorithm

This is an ordered algorithm, which means it sorts all pixelvalues and, starting at the lowest gray value, processes eachpixel exactly once. The algorithm requires three temporary im-ages. One temporary, binary image marks each pixel as activeor inactive. Initially, all pixels are active, and become inactive asthey are assigned their final value. The other two temporary im-ages, and , accumulate upstream and downstream lengthsfor each pixel. The upstream direction is given by the adjacencyrelation: for example when making horizontal paths, upstreamis to the E, and the set {NE, E, SE} are the upstream neighbors.The downstream direction is the opposite direction [in this caseto the West (W)]. These images are both initialized to , indi-cating that, for each pixel, at the initial gray level, it is possibleto draw a path in either direction of length . Since is thetarget length, it is not necessary to accumulate any value largerthan . As the algorithm progresses, and will decreasein value. For a pixel , is the length of thelongest path through it.

The initialization of and allows paths to extend in-definitely past the image boundary. In Appleton and Talbot’salgorithm, pixels closer to the boundary obtain lower values. Inthis way, paths are constrained to the image domain. There are

other ways to treat the boundary condition [3], but this is not ex-plored further in this paper. No boundary condition is correct ifit is not known what was outside the image. Therefore, it makessense to use the boundary condition that requires the least effortto implement or the least time to compute. Furthermore, addinga dark border around the image also constrains the paths in theopening to the image domain, but in a much simpler manner(use a light border for the closing).

After initialization, all pixels with the lowest gray value areselected for update, and the temporary and output images areupdated as detailed below. Then the next higher gray value ischosen, and all pixels with this value that are still active are se-lected for update, etc., until the highest gray value is reached. Itis possible to write directly in the input image, it is not neces-sary to create a separate output buffer.

At each threshold level , the selected pixels are processedtwice, once in the upstream direction and once downstream. Ineach of these passes, upstream/downstream pixels are iterativelyenqueued. Pixels on the queue need to be processed in the ap-propriate order. For example, when making horizontal lines, theupstream direction is E, meaning that in the upstream pass theenqueued pixels need to be processed from W to E. In the down-stream pass, the enqueued pixels need to be processed from Eto W.

In the upstream pass, for each of the selected pixels the cor-responding is set to 0 and the upstream neighbors areenqueued. Pixels in the queue are processed according to theirposition in the image, such that pixels further upstream are pro-cessed later. For each of the pixels in the queue, the maximum

of its downstream neighbors is found and increased by one.For horizontal paths this is

If this new value is smaller than , is assignedthe value and its upstream neighbors are also enqueued. Be-cause was initialized to , the update procedure automati-cally stops after steps.

In a second, downstream pass, is updated in a similar way.Next, For each of the pixels updated in these two passes, the

value is computed. If , the

Page 3: Constrained and Dimensionality-Independent Path Openings

LUENGO HENDRIKS: CONSTRAINED AND DIMENSIONALITY-INDEPENDENT PATH OPENINGS 1589

Fig. 2. Dimensionality-independent version of the path opening algorithm. See text for definition of variables.

pixel is not part of a path of length . The corresponding pixelin the output image is set to the current gray value . Becausethis pixel will also not be part of a longer path at higher grayvalues, is set to inactive and .

Note how, after sorting the image pixels by gray value, thereis no further comparisons of gray values. Therefore, to computethe closing instead of the opening, one need only change theinitial sort order, starting at the largest gray value.

B. Simplifying the Algorithm

The most complex part of the algorithm as described aboveis the queue used to process the pixels: depending on thechosen orientation, pixels need to be sorted in different ways.This sorting can be accomplished by writing four versionsof the algorithm, one for each possible orientation, but thatdoes not generalize to higher dimensional images. At theexpense of a slight increase in execution time, the abovealgorithm can be modified such that, instead of processingall pixels with identical gray value at the same time, theand update procedure is performed for each input pixelindependently. The pixel queue can now be implemented asa simple first-in, first-out (FIFO) queue. The recursive updatealgorithm only requires a list of offsets to the upstream anddownstream neighbors, such that, e.g., ,

and . By changing thisneighbor list, a different path orientation can be selected. Andby defining the neighbor list appropriately, the same algorithmcan process images of any number of dimensions.

This implementation of the algorithm starts by creating a listof linear indices (or memory addresses) to every pixel in theimage. It skips the border pixels to avoid tedious out-of-boundstests when indexing neighbors. The list of indices is then sortedaccording to the gray value of the input image (low to high forthe opening, high to low for the closing). The temporary im-ages , and described above are created and initialized.

is set to inactive for all the border pixels to stop the iterative

propagation routine when it reaches the image boundary. TwoFIFO queues are created, and . is the queue used forpropagating lengths. is a queue to which pixels are added forwhich either value changed, and avoids testing all pixels in theimage for changes at the end of every length propagation pass.The binary image is stored using one byte per pixel, which letstwo additional flags per pixel to be stored in the same space:and . When a pixel is added to , is set, indicating thatthe pixel need not be enqueued again; when the pixel is poppedfrom the queue, is reset. has the same function for queue

. These two flags are only used for efficiency, and could bedone without at the cost of longer queues and . The fullalgorithm is outlined in Fig. 2.

By not processing pixels on the boundary of the image, thealgorithm never changes their value. What is more, the pixels onthe image boundary do not influence the result of the operation.To circumvent this issue, it is possible to add a one-pixel borderaround the image.

C. Adjacency Relations in Dimensions

In the previous algorithm description, we did not specify howto create the offsets to the upstream and downstream neighbors,

and . This list is the only element of the algorithm thatcontains any notion of the image dimensionality. Let us assumethat the image is stored in a linear array such that adding the in-teger value to the address of any pixel yields the address of itsneighbor along the first dimension, adding yields the addressof the neighbor in the second dimension, etc. The values arecalled strides. In a 2-D image, for example, the NE neighbor of

is , and, therefore, the value is the offset tothe NE neighbor. This indexing does not work on border pixels,which is why the border pixels are not processed in the algo-rithm as described above. It is relatively easy to add the neces-sary tests to be able to process border pixels, but these signifi-cantly increase the execution time of the algorithm.

Fig. 3 outlines an algorithm to loop over every neighbor of apixel, no matter what the dimensionality is, and compute its

Page 4: Constrained and Dimensionality-Independent Path Openings

1590 IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 19, NO. 6, JUNE 2010

Fig. 3. Dimensionality-independent looping over all neighbors to create a list of offsets to neighboring pixels. See text for definition of variables.

offset based on the strides . It includes a test “ is close in di-rection to ”, to determine if a neighbor needs to be addedto the list of upstream neighbors , given the path’s main di-rection . Here, and are defined as vectors with elements,each one taken from the set , and point at a neighborpixel. The test “ is close in direction to ” is defined as follows:1) for at least one ; 2) for at least one ;and 3) for all values of . In 2-D, this producesthe same neighbor relations as in the original path opening def-inition [1]–[5]. In higher dimensions, it produces an equivalentgraph with paths that can bend in any direction.

D. Enumerating All Possible Orientations

To obtain a path opening that is not constrained to a specificorientation, one would take the supremum of the path openingsin each possible orientation. In 2-D, there are four possible ori-entations: 0 , 90 , 45 and . In dimensions, the numberof orientations is given by (this is half thenumber of neighbors of a pixel). Enumerating these orientationsis very simple, using a loop similar to that shown in Fig. 3. Thistime we do a simple test on to verify that it is on the positivehalf-sphere: the first nonzero element of must be positive.

III. CONSTRAINING PATH OPENINGS

The one issue with path openings using the adjacency rela-tions as defined previously concerns the length of diagonal paths(45 and paths). An opening will preserve a two-pixelwide line of certain length, but not a one-pixel wide line ofthe same length, because it can zig-zag in the wider line butnot in the thinner one. This effect is demonstrated in Fig. 4 andSection IV-C.

To reduce a path’s ability to zig-zag, it is possible to changethe adjacency graph. For example, Heijmans et al. mention thepossibility of an adjacency graph where even and odd steps aredifferent [3]. Their example graph [3, Figure 2d], forms verticalpaths from S to N; even rows are as described here, containingsteps either NW, N or NE; odd rows contain only steps in themain direction, N. This results in lines with at least half the stepsto the N, meaning its angle is more constrained and zig-zaggingis reduced. The negative side effect is that these openings arenot invariant to a translation of 1 pixel in the vertical direction,though translation invariance can be recovered by combiningthe output of two openings.

Fig. 4. The 45 path can have very different number of pixels depending on thewidth it is allowed to have. (a) When given the space, the path will zig-zag, re-sulting in a physically shorter path than expected given the pixel count (7 pixels).(b) The same physical length can be covered with fewer pixels (4 pixels). (c) Theproposed constraint does not completely avoid the zig-zagging of the path, butreduces its consequences to acceptable levels (5 pixels).

We propose to constrain paths in a similar manner, but withina single operation. When building the path with main direction

, a step in a direction other than must always be followedby a step . This is a less strict constraint than using the graphdescribed above because the restriction to the step is not givenby the location in the image, but rather by the previous steptaken. Fig. 4(c) gives an example. With this constraint the stepsin a direction other than can happen anywhere on the path, butit is not possible for two of these steps to happen consecutively.

To implement this idea, two additional temporary images arerequired: instead of one upstream and one downstream lengthimage, and , we need two of each, one for the normallength, and one for the constrained length: , , , and

. The constrained lengths are the lengths propagated fromthe pixel in the main direction , the normal length can be prop-agated from any of the possible directions. When propagatinglengths, the constrained length can be propagated to any direc-tion, whereas the normal length can only be propagated in themain direction. This implies that the constrained length must beused to update the next pixel’s normal length, and the normallength must be used to update the next pixel’s constrainedlength. Because constrained and normal lengths alternate, it isnecessary to add normal upstream and constrained downstreamlengths (and vice versa) when computing the total length of apath through a point . This length is thus given by

Furthermore, it can be shown that and . Themodified algorithm is given in Fig. 5.

Page 5: Constrained and Dimensionality-Independent Path Openings

LUENGO HENDRIKS: CONSTRAINED AND DIMENSIONALITY-INDEPENDENT PATH OPENINGS 1591

Fig. 5. Algorithm for the constrained path opening, compare to Fig. 2. See text for definition of variables.

Fig. 6. Example input image used for the results in Fig. 7.

IV. RESULTS

This section contains some experimental results that quantifyand compare the performance of the path openings as describedin this paper, and illustrate some possible uses for this operation.

A. Time Versus Accuracy

Path openings have many different possible applications. Themost obvious one is to filter the image, preserving line-like fea-tures while removing other features. The path opening has to beapplied once for each of the directions described in Section II-D,which is 4 in 2-D. The other method to accomplish this, usingopenings with straight line segments, becomes more accuratewith increasing number of orientations used [9]. Nonmorpho-logical methods such as the structure tensor [12] or directional

Fig. 7. Accuracy versus computation time of the various options to filter animage preserving linear structures. Values plotted are the mean over 50 repeti-tions. The thick bars indicate the 25th and 75th percentiles, the thin bars the tenthand 90th percentiles, and the dots to minimum and maximum errors. Isotropicopenings are included to show the upper limit on the error (cross at the top leftcorner of the graph). For openings with discrete and interpolated lines, the plotshows the result using round �� � orientations, with � increasing linearly from2 to 9 in steps of 0.5.

second derivatives (including steered filters [12]) are often em-ployed to detect linear features in images. There is, however,a significant difference between detecting and preserving: themorphological filters will keep the desired features unchangedwhile removing the nondesired ones, whereas the nonmorpho-logical filters will yield a strong response at the desired features,

Page 6: Constrained and Dimensionality-Independent Path Openings

1592 IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 19, NO. 6, JUNE 2010

Fig. 8. Line detection. (a) Input image, photograph of a printed circuit board. (b) Image filtered for diagonal lines using the supremum of the path openings at 45and��� . (c) Image filtered for horizontal lines using a path opening at 0 . (d) Image filtered for vertical lines using a path opening at 90 . (e) Image filtered forhorizontal lines using an opening with a straight line segment at 0 . (f) Image filtered for vertical lines using an opening with a straight line segment at 90 .

not preserving their intensities nor shapes. Therefore, we limitedthe following evaluation to the morphological methods.

To answer the question of how the path opening compares inquality to openings with straight line segments at the same ex-ecution time, and how the path opening compares in executiontime to openings with straight line segments at equal quality,the following experiment was carried out. Fifty synthetic im-ages were generated as follows, see Fig. 6. A grid of perpendic-ular lines cover the image. Each line was given a small randomrotation (between 0 and 1.9 ). The whole grid was rotated ran-domly, but avoiding angles close to 0 , 45 and 90 . Lines weregiven a Gaussian profile pixels . Note that the lineswere directly sampled in their final position in the image, therewas no resampling of the image to obtain the rotations. No noisewas added. A region around the boundary of the image is set toa high gray value to avoid edge effects. The images were 512 by512 pixels in size.

Both the path openings pixels and the openingswith straight line segments (length 50 pixels) were appliedto each image, and compared to the input image. The errormeasure used was the root mean square error, computed onlyon and close to the lines of the input image. The average errorfor each filter is plotted against computation time in Fig. 7.Openings with straight line segments were computed usingbetween 4 and 512 steps, and using two methods to computethe opening: discrete lines and interpolated lines [9]. The graphincludes results for both the standard path opening and theconstrained path opening. Constraining the path approximatelydoubles execution time, but does not affect the error measurein this experiment. The graph also includes the result for theisotropic opening (area equivalent to that of the line segments).The isotropic openings, not preserving linear structures, givesan upper bound for the error.

In this experiment, path openings produce results much betterthan those that can be produced with openings with straightline segments. The interpolated lines method obtains a min-imum at 91 orientations (the method does not improve muchwith more orientations, but the interpolation errors keep ac-cumulating, thereby slightly increasing the error measure). At91 orientations, the error is 50% larger than for the path open-ings, and the computation time four times as long as that of thepath openings. The difference in execution time increases forincreasing length, and decreases for decreasing length.

B. Detecting Lines Without Knowing Their Exact Orientation

In this example application, we apply the path opening filterto detect linear elements. Fig. 8(a) shows a photograph of aprinted circuit board. A simple top-hat filter [6] filters the imageso that only thin elements remain, independent of their length ororientation. The constrained path opening is then applied in allfour directions [Fig. 8(b)–(d)], leaving only elongated thin ele-ments that are approximately horizontal, vertical and diagonal.Note how the exact orientation of a line segment is irrelevant.Most notably, this makes the algorithm insensitive to distortionssuch as a small rotation, projective distortion and lens distor-tions. In contrast, using straight structuring elements requiresexactly matching the orientation of the structuring element withthe orientation of the lines to be detected. In Fig. 8(e)–(f), thesestraight line operators failed to correctly filter the image becausenone of the lines in the image are exactly horizontal or vertical.

C. Improved Length Estimation

This section studies the applicability of the path openingto construct a granulometry. For accurately measuring lengthusing a granulometry, the opening (or closing) filter mustremove all line segments shorter than a specified length , and

Page 7: Constrained and Dimensionality-Independent Path Openings

LUENGO HENDRIKS: CONSTRAINED AND DIMENSIONALITY-INDEPENDENT PATH OPENINGS 1593

Fig. 9. Three of the images used as input for the granulometries in Fig. 10.

not affect the ones longer than . The first problem that onenotices when studying the path openings is that diagonal pathsare longer than horizontal paths with the same parameter ,since this parameter specifies the number of pixels in the path,not its length. It is conceivable to modify the path openingalgorithm to more accurately measure path lengths, usingexisting perimeter estimation algorithms [13], [14]. Here, wewill ignore this problem, since, as shown in Section III, thezig-zag of the diagonal path opening introduces a much largerbias. This means that, in practice, diagonal paths are muchshorter than horizontal paths with the same parameter . Theconstrained path opening reduces this problem but does noteliminate it. As shown in the following experiment, the zig-zagin the constrained path opening approximately balances theincorrect length measure used in the algorithm, producing areasonable length estimate. There is no justification for thebalancing of these two effects; it just happens that counting thepixels of a line that slightly zig-zags as does the constrainedpath yields a reasonable estimate of the physical length of thepath.

Eight images as in Fig. 9 were generated. Each image con-tains 50 lines of 40 pixels length at the same orientation. Eightorientations were chosen at equal intervals between 0 and 45 .Each line has a Gaussian profile and a random sub-pixelshift, as in [9].

The cumulative length distributions for these eight imageswas computed with a granulometry, following reference [7],using one of the following three operations at each length scale: 1) the supremum of four unconstrained path openings with

, 2) the supremum of four constrained path openings with, and 3) the supremum of openings with straight

line segments (by interpolation) of length [9]. The length scaleaxis is sampled in increments of four pixels. The results areshown in Fig. 10. Ideally, the cumulative distribution is zero forlengths smaller than the length of the lines in the image (40pixels), and one for larger . Because of the Gaussian profileof the lines and inaccuracies in the operations, small deviationsare expected; a perfect result is not possible. For the horizontallines, all three methods produce a correct output, as expected.However, as the angle increases the unconstrained path openingyields an increasingly severe overestimation of the lengths of thelines [Fig. 10(a)], due to the zig-zagging discussed in Section III.By constraining the paths as proposed in this paper, the length ofdiagonal lines is measured much more accurately [Fig. 10(b)].Only the more computationally expensive and nonrobust third

Fig. 10. Length granulometries for the two images in Fig. 9. (a) Granulometryusing unconstrained path openings. (b) Granulometry using the constrained pathopenings proposed here. (c) Granulometry using the supremum over openingswith straight line segments at many angles.

method is rotationally invariant [Fig. 10(c)]. Very similar resultswere obtained with wider line segments in the input images (notshown).

D. Length Distribution of Wood Fibers in 3-D Images

Next, we applied the granulometry with path openings on aimage to demonstrate its usefulness for estimating length

distributions in 3-D images. Thermomechanically pulped(TMP) wood fibers were mixed with polylactide (PLA) asmatrix, at 10% weight fraction of fibers, and injection molded.A small cube of approximately mm was cut from thesample and imaged at the TOMCAT beamline at the Swiss

Page 8: Constrained and Dimensionality-Independent Path Openings

1594 IEEE TRANSACTIONS ON IMAGE PROCESSING, VOL. 19, NO. 6, JUNE 2010

Fig. 11. Three-dimensional ��� image of wood fibers embedded in plastic. (a) Slice of the input image. (b) Slice of the preprocessed image, to which thegranulometry is applied. (c) Slice from the result of the path opening, at � � �� pixels �� �� �m; (d) at � � � pixels �� �� �m; (e) at � � �� pixels�� �� �m; and (f) at � � �� pixels �� ��� �m.

Light Source (Paul Scherrer Institut, Villigen, Switzerland).The resulting volumetric image was cropped to pixelsand further downsampled to pixels. Fig. 11(a) shows themiddle slice from this volume, a little over m across.

The granulometry requires a uniform gray value over the ob-jects and the background if the goal is to obtain a size (or, asin this case, length) distribution [7]. Binarizing the image ac-complishes this, but makes a hard decision as to which pixelsare fiber and which ones are matrix. Instead, we choose to useclipping to make the foreground and background gray valuesuniform without modifying the gray values of the pixels at theedges of the objects. Using gray values in this way improvesthe results of the granulometry [15]. Before clipping the imageto the range , a bilateral filter (separable implementa-tion [16], spatial of 1 pixel, tonal of 10) was applied to re-duce noise. The result is shown in Fig. 11(b). This image is theinput to the granulometry using constrained path openings, asused in Section IV-C. Fig. 11(c)–(f) shows the middle slice ofthe filtering result at various length scales, demonstrating the in-creasing removal of fibers from the volume. Note that, becausethe fibers are not aligned with the cutting plane, their lengths arenot evident from the slice shown.

Fig. 12 shows the cumulative distribution (line plot, right ver-tical axis) for the image in Fig. 11(b), sampled twice per oc-tave. The bar graph in that figure is the derivative of the cumu-lative distribution, and thus an estimate of the volume-weighteddistribution of fiber lengths in the sample. Note, however, thatbecause of the boundary condition chosen (fibers touching theimage boundary are considered infinitely long and do not con-tribute to the distribution), the distribution underestimates theweight of the longer fibers. An unbiased measurement requires acomplex boundary condition, as is known from stereology [17].

Fig. 12. Cumulative distribution (line plot and right vertical axis) of fiberlengths in the volume image shown in Fig. 11, and its derivative (bar graph andleft vertical axis). The bar graph corresponds approximately to a log-normaldistribution.

V. CONCLUSIONS AND DISCUSSION

The algorithm presented here increases the computationalcost of the algorithm as presented by Appleton and Talbot.However, this increase is limited because the processing donefor one pixel potentially fixes the output value of many pixels,thereby reducing the work needed for subsequent pixels atthe same gray level. In return for the small increase in cost,the algorithm becomes simpler to implement, is applicableto images of any number of dimensions, and is applicable tofloating-point images (the original version of the algorithmassumes a limited set of gray values in the input image).

This opening algorithm processes gray values from lowestto highest. In contrast, an efficient algorithm to compute thearea opening processes gray values from highest to lowest (the

Page 9: Constrained and Dimensionality-Independent Path Openings

LUENGO HENDRIKS: CONSTRAINED AND DIMENSIONALITY-INDEPENDENT PATH OPENINGS 1595

down-hill algorithm) [18], [19]. Because the area opening issimilar to the path opening, it seemed at first that it should bepossible to write a similar algorithm for the path opening as well.This turned out to not be possible because the path opening doesnot consider the whole connected component as a single unit:different parts of a connected component can obtain differentgray values after the path opening operation. This is incompat-ible with the down-hill algorithm.

As mentioned earlier, the pixels at the border of the imageare not processed in order to keep the algorithm simple. Fur-thermore, due to the simple initialization, paths can extend in-definitely past the image boundary. This means that any paththat goes to the edge is assumed to be infinite in length. Boththese limitations can be overcome by adding a border aroundthe image. To limit paths to the image domain, a dark bordermust be added for the opening, or a light one for the closing.

The second modification proposed in this paper is the con-straining of the paths. By alternating between two connectivitygraphs, diagonal lines can not zig-zag as much. This signifi-cantly improves the length accuracy of the method, and therebyalso the rotation invariance. This constraint increases executiontime and memory usage, but does not make the algorithm muchmore difficult to implement. Additionally, the constrained pathsare more selective in orientation than the unconstrained paths:the unconstrained path opening is not able to separate the diag-onal lines from either the horizontal or vertical lines. Whetherthis point is positive of negative depends on the application.A different way of improving length accuracy is by using amore correct length measure. However, using any length mea-sure other than counting pixels would require a much more com-plex and costly algorithm.

In this paper, it is proposed to use the supremum over all pathopenings instead of the supremum over many openings withstraight line segments at different orientations. Path openingsproduce better results, even if the lines in the input image arestraight, because they do not need to exactly match the orienta-tion of the lines. Path openings are also faster for longer lines,due to the very large number of orientations required when usinglong lines (though for very short lines they might be less effi-cient). The higher the image dimensionality, the more time issaved by using path openings. An additional advantage is thatpath openings are insensitive to a small bending of the lines inthe input. Such bending can occur, e.g., due to lens aberrations,or can be inherent to the data, such as in the wood fiber exampleof Section IV-D. In this example, fibers can be bent or partlybroken, yet still need to be measured correctly. Using straightline segments, a bent fiber would be broken into shorter sec-tions in which straight lines do fit.

ACKNOWLEDGMENT

The author would like to thank H. Talbot for kindly makinghis path opening code available, as well as the reviewers, whoread the manuscript very thoroughly and whose comments andsuggestions improved this paper greatly. The image ofwood fibers shown in Fig. 11 was acquired on the TOMCATbeam line at the Swiss Light Source, Paul Scherrer Institut, Vil-ligen, Switzerland. The author would also like to thank all thepeople in the WoodFibre3D project for this image. The Wood-Fibre3D project is funded by the European Union through theWood-Wisdom-Net programme.

REFERENCES

[1] M. Buckley and H. Talbot, “Flexible linear openings and closings,” inMathematical Morphology and its Applications to Image and SignalProcessing, ser. Computational Imaging and Vision, J. Goutsias, L.Vincent, and D. S. Bloomberg, Eds. New York: Springer, 2000, vol.18, pp. 109–118.

[2] H. Heijmans, M. Buckley, and H. Talbot, “Path-based morphologicalopenings,” in Proc. Int. Conf. Image Processing (ICIP), 2004, vol. 5,pp. 3085–3088.

[3] H. Heijmans, M. Buckley, and H. Talbot, “Path openings and closings,”J. Math. Imag. Vis., vol. 22, no. 2–3, pp. 107–119, 2005.

[4] B. Appleton and H. Talbot, C. Ronse, L. Najman, and E. Decencière,Eds., “Efficient path openings and closings,” in Proc. 7th Int. Symp.Mathematical Morphology, 2005, vol. 30, pp. 33–42, ser. Computa-tional Imaging and Vision.

[5] H. Talbot and B. Appleton, “Efficient complete and incompletepath openings and closings,” Image Vis. Comput., vol. 25, no. 4, pp.416–425, 2007.

[6] P. Soille, Morphological Image Analysis: Principles and Applications,2nd ed. Berlin, Germany: Springer, 2003.

[7] C. L. Luengo Hendriks, G. M. P. van Kempen, and L. J. van Vliet, “Im-proving the accuracy of isotropic granulometries,” Pattern Recognit.Lett., vol. 28, no. 7, pp. 865–872, 2007.

[8] C. L. Luengo Hendriks and L. J. van Vliet, C. Arcelli, L. P. Cordella,and G. S. di Baja, Eds., “A rotation-invariant morphology for shapeanalysis of anisotropic objects and structures,” in Proc. 4th Int. Work-shop on Visual Form, Berlin, 2001, vol. 2059, pp. 378–387, ser. LectureNotes in Computer Science.

[9] C. L. Luengo Hendriks and L. J. van Vliet, “Using line segments asstructuring elements for sampling-invariant measurements,” IEEETrans. Pattern Anal. Mach. Intell., vol. 27, no. 11, pp. 1826–1831,Nov. 2005.

[10] S. Valero, J. Chanussot, J. A. Benediktsson, H. Talbot, and B. Waske,“Directional mathematical morphology for the detection of the roadnetwork in very high resolution remote sensing images,” in Proc. Int.Conf. Image Process., 2009, pp. 3725–3728.

[11] M. Buckley and J. Yang, “Regularised shortest-path extraction,” Pat-tern Recognit. Lett., vol. 18, no. 7, pp. 621–629, 1997.

[12] B. Jähne, Digital Image Processing, 5th ed. Berlin, Germany:Springer, 2002.

[13] L. Dorst and A. W. M. Smeulders, “Length estimators for digitizedcontours,” Comput. Vis., Graph., Image Process., vol. 40, no. 3, pp.311–333, 1987.

[14] D. Coeurjolly and R. Klette, “A comparative evaluation of length esti-mators of digital curves,” IEEE Trans. Pattern Anal. Mach. Intell., vol.26, no. 2, pp. 252–258, Feb. 2004.

[15] C. L. Luengo Hendriks, “Structure Characterization Using Mathemat-ical Morphology” Ph.D. dissertation, Delft Univ. Technology, Delft,The Netherlands, 2004.

[16] T. Q. Pham and L. J. van Vliet, “Separable bilateral filtering for fastvideo preprocessing,” presented at the IEEE Int. Conf. Multimedia andExpo Los Alamitos, CA, 2005.

[17] P. R. Mouton, Principles and Practices of Unbiased Stereology: AnIntroduction for Bioscientists. Baltimore, MD: Johns Hopkins Univ.Press, 2002.

[18] L. Vincent, “Grayscale area openings and closings, their efficient im-plementation and applications,” in Mathematical Morphology and ItsApplications to Signal Processing, J. Serra and P. Salembier, Eds.Barcelona, Spain: UPC, 1993, pp. 22–27.

[19] K. Robinson and P. F. Whelan, “Efficient morphological reconstruc-tion: A downhill filter,” Pattern Recognit. Lett., vol. 25, no. 15, pp.1759–1767, 2004.

Cris L. Luengo Hendriks (S’01–M’05) receivedthe M.Sc. and the Ph.D. degrees from the De-partment of Applied Physics, Delft University ofTechnology, Delft, The Netherlands, in 1998 and2004, respectively.

For four-and-a-half years, he was a visitingresearch fellow at Lawrence Berkeley NationalLaboratory, Berkeley, CA, where he collaboratedwith a large group of people to build the first 3-D,quantitative atlas of gene expression in the fruit flyembryo. Currently, he is an Associate Professor at

the Centre for Image Analysis in Uppsala, Sweden. He is founding author ofDIPimage, a MATLAB toolbox for scientific image analysis, and contributingauthor of DIPlib, the library on which DIPimage is built. His research interestswithin image analysis include quantification, mathematical morphology, linearmethods, and the link between the continuous and discrete domains.