我正在尝试找到骨架图像中最长的分支,并将最终图像显示为输出但是仍然存在于算法中。现在我能够找到一条线并在输出中绘制它。但我需要找到最长的线。这是我到目前为止所做的:
var vect1= new scala.collection.mutable.ArrayBuffer[Point]()
var p=new Point (0,0)
var res = new Array[Byte](1)
var u=skel.get(p.x.toInt,p.y.toInt,res)
var value1: Int=0
var value2: Int=0
scala.util.control.Breaks.breakable {
while((value1 < skel.rows ) ){
while ( (value2 < skel.cols )){
if (res(0) == -1) {
p.x=(p.x.toInt)+value1
p.y=(p.y.toInt)+value2
scala.util.control.Breaks.break()
}
value2=value2+1
skel.get(value1,value2,res)
}
value2=0
value1=value1+1
}
}
vect1 = traceLine(skel, p);
//inside traceLine the algorithm makes a vector and looks for 8 neighbors around the point to find the next available point and make the vector then return the result and save it into vect1.
val output= new Mat (skel.rows, skel.cols, CvType.CV_8UC3,new Scalar(0, 0, 0))
val it = vect1.iterator //Iterator(vect1)
var vect3=new Array[Byte](3)
vect3(0)=0
vect3(1)=255.toByte
vect3(2)=0
vect1.foreach(p => output.put(p.x.toInt, p.y.toInt, vect3))
问题是我如何返回最长的分支?