RIDGE AND TREE FEATURE DETECTION ON IMAGES1

A. Levashov 2, D. Yurin3

2, 3 Laboratory of Mathematical Methods of Image Processing Faculty of Computational Mathematics and Cybernetics Lomonosov Moscow State University Leninskie Gory, Moscow 119991, Russia [email protected] , [email protected]

In this article a new ridge detector with improved non-maxima suppression procedure in scale-space is proposed. Using the results of ridge detection as primary markup the lines are prolonged up to branch points and restored in places where they are not detected. In our method the adaptive choice of threshold and flood fill are used. The algorithm is tested on synthetic, landscape and medical images.

Introduction bigger scale (two times or more which leads to lines breakdown). Third, the filter response There are several major algorithms for ridge can diminish due to inconsistency between ac- detection. Apparently the first of them was the tual image structure and ridge mathematical approach [2] that does not use scale-space model, which implies: the solid color line in analysis and therefore its disadvantage is that the range of central lobe of the second deriva- it detects only thin lines. The approach [5] is tive of Gaussian function and background with based on the scale-space analysis, but it repre- another color on the sidelobes. This article is sents the theoretical basis for it and not practi- devoted to suppression of disadvantages de- cally effective algorithm. For the last 15 years scribed above. there have been only a few cases where it was used in scientific researches. The detector [3] The ridge detection based on generalization of NMS for the case of 3d scale space (x, y, t) can been seen as more In this section we shortly recall the algorithm effective for ridge detection. However one of [3], let  , yxI  is the intensity of input gray- this approach`s disadvantages is that it does scale image. Scale space [6] is defined as con- not detect the branch points on the lines and in volution of the image , yxI  with Gaussian the adjacent areas. It interrupts the lines con- kernel: nection and significantly complicates the tree      yxItyxGtyxL ),,(,,,, structure analysis on images. The examples of  yx 22 such tasks are masking of tree branches and 1  (1) ,, tyxG  e 2t t   2 ,, wires on the non-professional photos for re- 2t touching, road and river net finding on aero- We denote smoothed image ,, tyxL  deriva- space images for the cartographic information updating, selection of blood veins on medical tives with subscripts as LLLLL yyxyxxyx ,...,,,, . images and processing of 3D images of com- Such derivatives are equivalent to original im- puter tomography for medical diagnostic. The age  , yxI  convolution with appropriate de- branch points are essential for such tasks, but rivatives of Gauss function ,, tyxG . By di- often the lines are not detected in the adjacent rect differentiation it is easy to check [6] that areas for several reasons. First, there is an am- scale-space representation of image ,, tyxL biguity in choosing the direction for NMS pro-   cedure, because the eigenvalues are almost is satisfied to diffusion equation: 1 equal. Second, in the adjacent areas two or   LLL , (2) more ridges lie closely and, as a result, La- t 2 yyxx place operator can give a maximal response on where derivatives are computed at scale t .

1 The research was supported by the RFBR grant 13-07-00584. Consider the algorithm [3] for ridge detection scales. Processing such layers triplets sequen- with branch points missing. Let the thickness tially under  i increasing, the local maximum of lines is fixed and equal 2 , then filter for points are collected. ridge lines finding can be the Laplace operator or maximal eigenvalue of Hessian H 22 in False detection suppression point , yx The method [3] outlined above detects also  LL xyxx  such features as blobs and some edges. In our H   , (3) 22   approach the final results are presented in vec-  LL yyxy  where the derivatives are computed on scale tor form instead of bitmap. After detection of ridges their spine pixel chains are collected in 2 , yx t   . In each point  we have a pair of lists and the lists are united in a graph. For ex- eigenvectors:  , vv 21 , where v1 corresponds cluding blobs, the lists with small count of to eigenvalue  such that   and v is pixels are discarded. It is important that the 1 21 1 minimal count of pixels in list is proportional normal to ridge. On this basis we obtain the to the ridge (or thick line) width. That is we algorithm of ridge lines detection as local impose a constraint for minimum elongation of maxima finding task (we find directional local the blobs, which are considered as ridges. This maxima and minima of values 1 in direc- approach is differ from [3] where separation of ridges and blobs is based on ratio of eigen val- tion v1 ), i.e. we use the Non Maxima Supres- sion (NMS) procedure with 3x3 window from ues of (3). . If the detection scale t For suppression of edges in [3] in NMS proce- does not equal to thickness of line, the re- dure the points are discarded if next dot prod- sponse of Laplacian (which is equal to uct is negative:    ,   vxgvxg   0 . (5) LLL   ) or eigen value  is   1   1  yyxx 21 1 Our experiments show that condition (5) can less than that of for scale is equal to thickness. lead to erroneous discarding true ridge centers Then if we analyze the response on neighbor- for example in cases when different side’s hoods scales we can choose the optimal scale. backgrounds relatively to ridge have a differ- In scale-space the 3D Hessian is: ent average intensity. We propose the modifi-  LLL   xtxyxx  cation of this condition:       H33   LLL ytyyxy  , where using (2)     i 1 ,   i vxgvxg 1   Tg (6)  LLL   ttytxt  where  i corresponds to current scale, the 1 1 (4) threshold constant satisfied the inequality: xt xxx  xyy , yt xxy  LLLLLL yyy , 2 2 Tg  01 , (7)

1 tt xxxx 2 xxyy  LLLL yyyy .  T 4 g  LL yx ),( is the image intensity gradient.

In [3] the NMS procedure was modified as fol- Adaptive flood-fill lows: the suppression is performed simultane- ously in 2 directions of 3D scale space (x,y,t) After the previous step we obtains the set of using 3x3x3 window. The directions are se- detected ridges represented as set of points lected as projections of 2 eigenvectors corre- S  x  ,, l jjj , where x j – the coordinates sponding to 2 maximal eigenvalues of (4) on of center points of ridge lines,  j – the scale, the plane normal to eigenvector v of 2D 2 at which we detect ridge point with coordi- Hessian (3). The discrete step on scales nates x , l – the response value in this point ,...,,...,  in [3] are chosen as in [7]: j j 0 ni (the response of Laplacian convolution com- 4 0 ,1 1   ii 2 . For 3D NMS procedure puted on scale  j ). Using this data, we build 3 implementation it is sufficient to hold in mem- images ,, IIM . We set M x  1 if pixel ory only 3 layers corresponding to 3 sequential min max  belongs to ridges, and M x  0 elsewhere. described, for example, in [1], and can easy be , II – additional images showing the modified for our problem by including addi- min max tional conditions for pixel filling (9), (10). available ridges points intensity range. Let ini- tially in all points M x  0 . Then for each Ridge skeletization points x j  S we set The binary image M after the previous step M x j  ,1 max j xx j  lII j ,5.0 will segment the image into the pixels belong- (8) ing to the ridges and the background pixels. xx  lII .5.0 min j j j When at branch points the ridges change their As shown in [3], the Laplacian value on scale color slightly in comparison with the back- corresponding to ridge thickness is equal to ground, the junction points will be added to difference of average intensities of background the ridges, even if they were not found by the and of ridge. scale-space detector. Further the continuous Then we make flood fill of image M . The skeletization of binary image can be applied proposed algorithm is similar to [1], but we and the skeleton can be used as the result. We use additional conditions for pixel filling. use the algorithm [9], because in our approach

Consider two neighborhood pixels y k and y j - it is desirable to retain the ridge points found by scale-space detector and only add junction M y   M y   0,1 . If the condition k j and junction neighborhood ridge points as a

min  k   j  III max yyy k , (9) result of thinning. The algorithm of skeletiza- is satisfied, we modify the pixel y as: tion via line thinning is based on step-by-step j removing of the points which are not the cen- M y j  ,1 min  j   II min yy k , ters in lines under additional condition that it is (10)  II yy . not ridge point obtained with scale-space de- max j max k tector. Each algorithm iteration includes two Now we can describe the algorithm of adap- passes through all the pixels. On each pass the tive flood fill: non-skeleton points are marked but removed Алгоритм AdaptiveFloodFill( x , d ) only after the end of the pass. Around each 1. if M x  1 return point x of the image M the window 3x3 is selected. We can enumerate pixels ,...,, PPP 2. if  min   IIINOT max xdxx  921 return is the window in order shown on the Fig.1. 9 3. M  dx   1 Descriptors and A x)( which is x)(   PB i I  I xdx i2 min min  equal to the number of patterns 01 in the se-

I max  I max xdx quence ,,..., PPP 292 are calculated. 4. AdaptiveFloodFill (  dx , 10 T ) 5. AdaptiveFloodFill (  dx , 01 T ) 6. AdaptiveFloodFill (  dx , 10 T ) T 7. AdaptiveFloodFill (  dx ,  01 ) Figure 1: pixel`s order in 3x3 window In the beginning of the algorithm for each points i M xx i  0)(: and for each neighbor- On the first pass the pixel x is marked to be removed from image M if all four next condi- hoods  dx we invoke the algorithm Adap- i tions are satisfied: tiveFloodFill( , dx ), which differs from [1] i a)  B x  6)(2 by 2 and 3 lines. For near border pixels we ad- b) A x 1)( ditionally check when coordinates  dx are outside of image rectangle. This is the scheme c)  2   4  PMPMPM 6   1 of simple and not optimal realization of the d)  4   6  PMPMPM 8   1 flood filling algorithm. The faster algorithm is

On the second pass clauses c) and d) are nected Component Labeling of Streamed changed to the following: Images" // Field-Programmable Technol- ogy, Int. Conf, -P. 159−165, 2012 c')  2   4  PMPMPM 8   1 [5] T. Lindeberg, " and ridge d') PMPMPM  1  2   6   8  detection with automatic scale selection" // International Journal of , - The iterations are being done until no pixels V. 30, -No. 2, -P. 117–154, 1998 are removed during two passes. As we don’t [6] T. Lindeberg “Scale-Space Theory in remove pixels detected by the scale-space al- Computer Vision” // Kluwer Academic gorithm, all the lines found initially retains and Publishers/Springer, Dordrecht, Nether- only the junction points between them are ap- lands, 1994. pended. [7] D.G. Lowe. “Distinctive image features Results and conclusion from scale-invariant keypoints” // Int. Journal of Computer Vision, -V. 60, -No. The ridge detection algorithm without brakes 2, -P. 91−110, 2004 near branch points is proposed. We make some [8] M.B. Dillencourt, H. Samet, M. Tamminen improvements in algorithm [3] and restore (1992). "A general approach to connected- breaks in ridges near branch points with adap- component labeling for arbitrary image tive flood fill algorithm. We test our approach representations" // Journal of the ACM, -V. on synthetic and medical images. Some results 39, -N. 2, -P. 253−280, 1992 for medical retina images are shown on Fig. 2. [9] T.Y. Zhang, C.Y. Suen “A fast parallel al- The ridges in the Fig. 2b have brakes near gorithm for thinning digital patterns” // branch points while in the Fig. 2c most of Communications of the ACM, -V. 27, -No. these brakes are restored and shown in red. 3, -P. 236−239, 1984. One of the disadvantages of the proposed algo- rithm is that our method does not detect the accurate ridge edges. But after we restore the ridges interconnections, the problem simplifies to finding edges between object (ridges united in tree) and the background. The task becomes bipolar labeling problem and can be solved via graph minimal cut between source (the set of connected ridge central points) and sink (back- ground, or the points lying far from ridges a) b) longer than the ridge width).

References

[1] S.V. Burtsev, Y.P. Kuzmin. “An efficient flood-filling algorithm” // Computers & graphics, Elsevier, -V. 17, -No 5, -P. 549– 561, 1993 [2] R. Haralick, "Ridges and Valleys on Digi- tal Images" // Computer Vision, Graphics, and Image Proc., -V. 22, -No. 10, 1983 [3] N. A. Khanina, E. V. Semeikina, D. V. Yu- rin. “Scale-space color blob and ridge de- tection” // Pattern Recognition and Image Analysis, -No. 1, -P. 221−227, 2012 [4] M. Klaiber, L. Rockstroh, Z. Wang, Y. Ba- c) roud, S. Simon. "A Memory-Efficient Par- Figure 2: a) Input image, b) scale-space ridge allel Single Pass Architecture for Con- detection, c) the result of line connection