Skip to main content
. 2018 May 29;18(6):1746. doi: 10.3390/s18061746
Algorithm 3 Separation algorithm of Image Processing Module
Input: An image of touching-pigs
Output: An image of individually separated pigs
// Hole generation
Check natural holes from the touching-pigs
If any hole is not detected
  Generate artificial holes with erosion or skeleton operator
// Guideline generation
Select two points with the longest distance in each hole
Semi-guideline = Connect (two points of each hole)
Guideline = Connect (all of the semi-guidelines)
// CP generation
ConvexHull (shape of the touching-pigs)
Make time-series data L and G
Find candidates of CPs with time-series data L
Find at most two CPs from the candidates with time-series data G
// Segmentation using guideline and CPs
If the number of final CPs is two
  Connect (guideline, concave points)
Else if the number of final CPs is one
  Connect (guideline, CP, selected point in the searching region)
Else if there is no CP
  Connect (guideline, the closest point, selected point in the searching region)
Return;