t ▁matter ▁which ▁one ). ▁Ind icate ▁that ▁all ▁of ▁these ▁regions ▁are ▁equivalent . ▁ ▁Sc an ▁image ▁again , ▁assigning ▁all ▁equivalent ▁regions ▁the ▁same ▁region ▁value . ▁ ▁O thers ▁Some ▁of ▁the ▁steps ▁present ▁in ▁the ▁two - pass ▁algorithm ▁can ▁be ▁merged ▁for ▁efficiency , ▁allowing ▁for ▁a ▁single ▁swe ep ▁through ▁the ▁image . ▁Multi - pass ▁algorithms ▁also ▁exist , ▁some ▁of ▁which ▁run ▁in ▁linear ▁time ▁relative ▁to ▁the ▁number ▁of ▁image ▁pixels . ▁ ▁In ▁the ▁early ▁ 1 9 9 0 s , ▁there ▁was ▁considerable ▁interest ▁in ▁parallel izing ▁connected - component ▁algorithms ▁in ▁image ▁analysis ▁applications , ▁due ▁to ▁the ▁bott l ene ck ▁of ▁sequ entially ▁processing ▁each ▁pixel . ▁ ▁The ▁interest ▁to ▁the ▁algorithm ▁ar ises ▁again ▁with ▁an ▁extensive ▁use ▁of ▁C U DA . ▁ ▁Mat lab ▁code ▁for ▁the ▁one - component - at - a - time ▁algorithm ▁ ▁Algorithm : ▁Con ne cted - component ▁matrix ▁is ▁initialized ▁to ▁size ▁of ▁image ▁matrix . ▁A ▁mark ▁is ▁initialized ▁and ▁increment ed ▁for ▁every ▁detected ▁object ▁in ▁the ▁image . ▁A ▁counter ▁is ▁initialized ▁to ▁count ▁the ▁number ▁of ▁objects . ▁A ▁row - major ▁scan ▁is ▁started ▁for ▁the ▁entire ▁image . ▁If ▁an ▁object ▁pixel ▁is ▁detected , ▁then ▁following ▁steps ▁are ▁repeated ▁while ▁( Index ▁!= 0 ) ▁Set ▁the ▁corresponding ▁pixel ▁to ▁ 0 ▁in ▁Image . ▁A ▁vector ▁( Index ) ▁is ▁updated ▁with ▁all ▁the ▁neighbor ing ▁pixels