▁with ▁the ▁conditions ▁highlight ed ▁above . ▁ ▁The ▁label ▁equivalence ▁relationships ▁generated ▁are , ▁▁ 3 . ▁Array ▁generated ▁after ▁the ▁mer ging ▁of ▁labels ▁is ▁carried ▁out . ▁Here , ▁the ▁label ▁value ▁that ▁was ▁the ▁smallest ▁for ▁a ▁given ▁region ▁" f lo ods " ▁throughout ▁the ▁connected ▁region ▁and ▁gives ▁two ▁distinct ▁labels , ▁and ▁hence ▁two ▁distinct ▁labels . ▁▁ 4 . ▁Final ▁result ▁in ▁color ▁to ▁clearly ▁see ▁two ▁different ▁regions ▁that ▁have ▁been ▁found ▁in ▁the ▁array . ▁ ▁The ▁pseudo code ▁is : ▁▁ ▁algorithm ▁Two Pass ( data ) ▁is ▁▁▁▁▁ ▁linked ▁= ▁[] ▁▁▁▁▁ ▁labels ▁= ▁structure ▁with ▁dimensions ▁of ▁data , ▁initialized ▁with ▁the ▁value ▁of ▁Background ▁▁▁▁▁▁▁▁▁ ▁First ▁pass ▁▁▁▁▁▁▁▁▁ ▁for ▁row ▁in ▁data ▁do ▁▁▁▁▁▁▁▁▁ ▁for ▁column ▁in ▁row ▁do ▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁if ▁data [ row ][ column ] ▁is ▁not ▁Background ▁then ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁ ▁neighb ors ▁= ▁connected ▁elements ▁with ▁the ▁current ▁element ' s ▁value ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁ ▁if ▁neighb ors ▁is ▁empty ▁then ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁ ▁linked [ Next Label ] ▁= ▁set ▁containing ▁Next Label ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁ ▁labels [ row ][ column ] ▁= ▁Next Label ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁ ▁Next Label ▁+= ▁ 1 ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁ ▁else ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁ ▁Find ▁the ▁smallest ▁label ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁ ▁L ▁= ▁neighb ors ▁labels ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁ ▁labels [ row ][ column ] ▁= ▁min ( L ) ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁ ▁for ▁label ▁in ▁L ▁do ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ ▁▁▁▁▁▁▁▁▁ ▁linked [ label ] ▁= ▁union ( link ed [ label ], ▁L ) ▁▁▁▁▁▁▁▁▁ ▁Second ▁pass ▁▁▁▁▁▁▁▁▁