▁of ▁the ▁current ▁element ▁ ▁If ▁there ▁are ▁no ▁neighb ors , ▁uniqu ely ▁label ▁the ▁current ▁element ▁and ▁continue ▁ ▁Otherwise , ▁find ▁the ▁neighbor ▁with ▁the ▁smallest ▁label ▁and ▁assign ▁it ▁to ▁the ▁current ▁element ▁ ▁Store ▁the ▁equivalence ▁between ▁neighbor ing ▁labels ▁ ▁On ▁the ▁second ▁pass : ▁Iter ate ▁through ▁each ▁element ▁of ▁the ▁data ▁by ▁column , ▁then ▁by ▁row ▁If ▁the ▁element ▁is ▁not ▁the ▁background ▁ ▁Rel abel ▁the ▁element ▁with ▁the ▁lowest ▁equivalent ▁label ▁ ▁Here , ▁the ▁background ▁is ▁a ▁classification , ▁specific ▁to ▁the ▁data , ▁used ▁to ▁distinguish ▁sal ient ▁elements ▁from ▁the ▁for eground . ▁If ▁the ▁background ▁variable ▁is ▁omitted , ▁then ▁the ▁two - pass ▁algorithm ▁will ▁treat ▁the ▁background ▁as ▁another ▁region . ▁ ▁Graph ical ▁example ▁of ▁two - pass ▁algorithm ▁▁▁ 1 . ▁The ▁array ▁from ▁which ▁connected ▁regions ▁are ▁to ▁be ▁extracted ▁is ▁given ▁below ▁( 8 - connect ivity ▁based ). ▁ ▁We ▁first ▁assign ▁different ▁binary ▁values ▁to ▁elements ▁in ▁the ▁graph . ▁The ▁values ▁" 0 ~ 1 " ▁at ▁the ▁center ▁of ▁each ▁of ▁the ▁elements ▁in ▁the ▁following ▁graph ▁are ▁the ▁elements ' ▁values , ▁whereas ▁the ▁" 1 , 2 ,..., 7 " ▁values ▁in ▁the ▁next ▁two ▁graphs ▁are ▁the ▁elements ' ▁labels . ▁The ▁two ▁concepts ▁should ▁not ▁be ▁confused . ▁▁ 2 . ▁After ▁the ▁first ▁pass , ▁the ▁following ▁labels ▁are ▁generated : ▁ ▁A ▁total ▁of ▁ 7 ▁labels ▁are ▁generated ▁in ▁accord ance