Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/algorithm/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Algorithm 在二值图像中寻找最长分支_Algorithm_Scala_Opencv_Search_Image Processing - Fatal编程技术网

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”标签。这是一个错误,谢谢您的编辑!