I'm working on a code to find the longest branch and here is a function to find the next unvisited point in my binary image: Note: I am saving the arraybuffer of found pixels in vectVisitedPoint.
var vectVisitedPoint= new scala.collection.mutable.ArrayBuffer[Point]()
var pTemp=new Point (0,0)
var res = new Array[Byte](1)
img.get(pTemp.x.toInt,pTemp.y.toInt,res) //img is a binary image
var value1: Int=0
var value2: Int=0
scala.util.control.Breaks.breakable {
while((value1 < img.rows ) ){
while ( (value2 < img.cols )){
if (res(0) == -1 && vectVisitedPoint.exists(_ == (value1, value2))) {
pTemp.x=(pTemp.x.toInt)+value1
pTemp.y=(pTemp.y.toInt)+value2
vectVisitedPoint.append(new Point(pTemp.x,pTemp.y)
scala.util.control.Breaks.break()
}
value2=value2+1
img.get(value1,value2,res)
}
value2=0
value1=value1+1
}
}
}