CHAPTER 3 METHODOLOGY
3.3 Image Processing Algorithms
3.3.2 Multi-stencils Fast Marching Method
Because the branches and seedpods of the canola plants are too small and thin, detecting and counting canola branches and seedpods bring many obstacles for crop researchers. From their characteristics, an idea to deal with this is to find the skeleton of the canola plant, then apply other detecting and counting algorithms. The skeleton describes simple and compact shapes of a plant with all features of the original plant. An example of the skeleton of a plant is shown in Figure 3- 7.
Figure 3-7. General concept of skeleton
Skeletonization algorithms can be classified into four main categories, morphological thinning algorithms, Voronoi diagram based algorithms, distance transform based algorithms, and mathematical morphology based on algorithms [98]. These morphological thinning methods iteratively remove the boundary layer by layer and can preserve the object topology. However, they are sensitive to the boundary noise and do not generate a true skeleton.Geometric approaches calculate the Voronoi diagram of a discrete polyline like a sampling of the boundary. These methods result in an accurately connected skeleton by increasing the sampling rate, but relatively complicated to implement as well as computationally expensive. Authors in [99] reviewed some algorithms used mathematical morphology for skeleton calculation, such as using influence zones and setting operations to transform a discrete binary image using parts of its skeleton containing complete information about its shape and size. The limitations of such methods are that their
34
outcomes depend on structure elements used for mathematical morphology operations. Also, the resulting skeletons may not preserve connectedness. The distance transform methods calculate the shortest distance from a given point to the object boundary. Approaches based on distance transform are expected to show a better performance under rotation and at sharp corners due to the robust underlying strategy of using the distance transform or depth measure, in defining the peel sequence [99]. Therefore, distance transform-based approaches have been studied, especially; a high accuracy fast marching method was used.
Fast marching methods are techniques designed to solve the Eikonal equation ( 𝑇𝑖2+ 𝑇𝑗2 = 1/𝐹{𝑖,𝑗)2 , where 𝑇 is travel time, ij represent Cartesian coordinates) for detecting the evolution of a monotonically advancing front. These approaches produce consistent, accurate, and highly efficient algorithms due to entropy-satisfying upwind schemes and fast sorting techniques. There are several improved fast marching methods, such as the Higher Accuracy Fast Marching, Untidy Fast Marching, Shifted Grid Fast Marching, and Multi-stencils Fast Marching (MFM) methods. These methods have been introduced to enhance the accuracy of predictions. Most of all algorithms, except the MFM algorithm, ignore information of nodes in the diagonal direction while considering only the 4-connected neighboring nodes in the 2D plane; therefore, they cause significant numerical errors along the diagonal directions. By utilizing information from all neighboring nodes (8-connected neighbors), the MFM algorithm solves this obstacle. The algorithm proposed by [100] is applied in this study because this technique improves version of the MFM that is highly accurate. This method computes the solution at each grid point by solving the Eikonal equation along several stencils that cover the entire nearest neighbors of the point and then picks the solution that satisfies the upwind condition. In addition, the accuracy of the MFM approach is further improved by using second-order finite difference schemes from the Eikonal equation.
In the MFM algorithm, the computation of the arrival time Ti, j includes two different
equations; the nearest neighbor points are covered by S1, whereas the diagonal neighbor ones are
35
Figure 3-8. The stencils for the 2D Cartesian domain. (a) S1 stencil and (b) S2 stencil • S1 stencil computation: Assuming we have a regular grid, the first-order equation
of this stencil aligned with the natural coordinate system is solved by the following equation: ∑ max (𝑇𝑖,𝑗 − 𝑇𝑣 ℎ , 0) 2 = 1/𝐹𝑖,𝑗2 2 𝑣=1 , (3.8)
where ∆𝑖 = ∆𝑗 = ℎ is the distance between nodes and
𝑇1 = min(𝑇𝑖−1,𝑗, 𝑇𝑖+1,𝑗), (3.9) 𝑇2 = min (𝑇𝑖,𝑗−1, 𝑇𝑖,𝑗+1). (3.10) On the other hand, for a second-order approximation of the directional derivative, this equation must be solved:
∑ max (3 2ℎ[ 𝑇𝑖,𝑗 − 𝑇𝑣 ℎ ], 0) 2 = 1/𝐹𝑖,𝑗2 2 𝑣=1 (3.11) where 𝑇1 = min (𝑇𝑖−1,𝑗 − 𝑇𝑖−2,𝑗 3 , 𝑇𝑖+1,𝑗 − 𝑇𝑖+2,𝑗 3 ) (3.12) 𝑇2 = min ( 𝑇𝑖,𝑗−1 − 𝑇𝑖,𝑗−2 3 , 𝑇𝑖,𝑗+1 − 𝑇𝑖,𝑗+2 3 ) (3.13)
• S2 stencil computation: Similar to the previous case, for a first-order
approximation of the diagonal equations, the following equation is solved: ∑ max (𝑇𝑖,𝑗 − 𝑇𝑣 √2ℎ , 0) 2 = 1/𝐹𝑖,𝑗2 2 𝑣=1 , (3.14) where 𝑇1 = min(𝑇𝑖−1,𝑗−1, 𝑇𝑖+1,𝑗+1), (3.15) 𝑇2 = min (𝑇𝑖+1,𝑗−1, 𝑇𝑖−1,𝑗+1). (3.16) and the second order equation is given by:
36 ∑ max ( 3 2√2ℎ[𝑇𝑖,𝑗− 𝑇𝑣], 0) 2 = 1/𝐹𝑖,𝑗2 2 𝑣=1 (3.17) where 𝑇1 = min (𝑇𝑖−1,𝑗−1 − 𝑇𝑖−2,𝑗−2 3 , 𝑇𝑖+1,𝑗+1 − 𝑇𝑖+2,𝑗+2 3 ) (3.18) 𝑇2 = min (𝑇𝑖+1,𝑗−1 − 𝑇𝑖+2,𝑗−2 3 , 𝑇𝑖−1,𝑗+1 − 𝑇𝑖−2,𝑗+2 3 ) (3.19)
For both stencils S1 and S2, if
𝑇𝑖,𝑗 > max(𝑇1, 𝑇2) (3.20)
then (3.8), (3.11), (3.14), and (3.17) can be simplified to 𝑔(ℎ) ∑ 𝑎𝑣(𝑇𝑖,𝑗) 2 + 𝑏𝑣𝑇𝑖,𝑗+ 𝑐𝑣 = 1 𝐹𝑖,𝑗2 2 𝑣=1 (3.21) where [𝑎𝑣 𝑏𝑣 𝑐𝑣] = [1 −2𝑇𝑣 𝑇𝑣2] (3.22) The value of g(h) for the first and second-order numerical schemes, as well as the stencil orientation, is given in Table 3-2.
Table 3-2. Values of first and second-order schemes
Stencil First order scheme Second order scheme 𝑆1 𝑔(ℎ) = 1 ℎ⁄ 2 𝑔(ℎ) = 9 4ℎ⁄ 2 𝑆2 𝑔(ℎ) = 1 2ℎ⁄ 2 𝑔(ℎ) = 9 8ℎ⁄ 2
• Upwind condition: As a result, the upwind condition is given by the following equation:
|𝑇1− 𝑇2| <
𝑓(∆𝑖,∆𝑗) sin ∅
𝐹𝑖,𝑗 (3.23)
The value of 𝑓(∆𝑖, ∆𝑗), for the first and second-order numerical schemes, as well as the stencil orientation, is given in Table 3-3.
Table 3-3. Coefficients of the upwind condition for both S1 and S2
Stencil First order scheme Second order scheme
𝑆1 𝑓 = min (∆𝑖, ∆𝑗) 𝑓 = 2 min (∆𝑖, ∆𝑗) 𝑆2 𝑓 = √∆2𝑖 + ∆2𝑗 𝑓 = 2 √∆2𝑖 + ∆2𝑗
37