function ALGORITHM (image_height, image_width, image, threshold) return centroids’ coordinates of each | identified PL | inputs: image_height, height of the image | image_width, width of the image | image, captured grayscale image | threshold, lower limit of brightness to identify pixels belonging to PL blob | /⋆ recursive function to compute the connected components of a binary image ⋆/ | LB ← (−1)⋆ threshold(image, threshold) | label ← 0 | for ← 0 image_height | for ← 0 image_width | if [L,P] = −1 then | label ←label + 1 | SEARCH(LB, label, L, P) | /⋆ FINDCENTROID function returns centroid of just labeled region ⋆/ | (centroids.row[label], centroids.col[label]) ← FINDCENTROID(LB, L, P, label) | return (centroids.row, centroids.col) | | function SEARCH(LB, label, L, P) | LB[L,P]← label | Nset← NEIGHBORS(L,P) | for each Nset | LB = −1 then | SEARCH(LB, label, , ) |
|