Algorithm 在二值图像中寻找最长分支
我试图在骨架图像中找到最长的分支,并将最终图像显示为输出,但仍停留在算法中。现在我能够找到一条线并在输出中绘制它。但我需要找到最长的线路。这就是我到目前为止所做的:Algorithm 在二值图像中寻找最长分支,algorithm,scala,opencv,search,image-processing,Algorithm,Scala,Opencv,Search,Image Processing,我试图在骨架图像中找到最长的分支,并将最终图像显示为输出,但仍停留在算法中。现在我能够找到一条线并在输出中绘制它。但我需要找到最长的线路。这就是我到目前为止所做的: 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 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))
var vect1=new scala.collection.mutable.ArrayBuffer[Point]()
var p=新点(0,0)
var res=新数组[字节](1)
var u=skel.get(p.x.toInt,p.y.toInt,res)
变量值1:Int=0
变量值2:Int=0
scala.util.control.Breaks.breakable{
而((值1output.put(p.x.toInt,p.y.toInt,vect3))
问题是我怎样才能退回最长的树枝 为什么git在标签中?@VikramBhat谢谢你的指点。删除了“git”标签。这是一个错误,谢谢您的编辑!