垂直投影
プライベートorg.opencv.core.Mat projectionVerticality(org.opencv.core.Mat MAT){ org.opencv.core.Mat projectionMat = mat.clone(); // Quxianjiuguoは、MATとして取り込む projectionMat.setTo(新しい新しい ORG .opencv.core.Scalar(255)); // その後白色に入れ ダブル[] = dotList 新しい新しいダブル[mat.cols()]; //は、各列の黒ドットの数を格納するためのリスト作成 システム.loadLibrary(Core.NATIVE_LIBRARY_NAME) のSystem.out.println(mat.dump()); INT COL = mat.cols(); int型の行= mat.rows(); のための(INT X = 0; X <COL。 X ++){ dotList [X] = 0.0 。 用(INT Y = 0; Y <行; Y ++ ){ ダブル BINDATA = mat.get(Y、X)[0 ]; もし(BINDATA == 0){ // 黑色 dotList [X] ++ ; } } } // 然后生成投影图 ため(int型のx = 0; X <mat.cols(); X ++ ){ ため(int型、Y = 0; Y <mat.rows(); Y ++ ){ 場合(X == 147){ System.out.println( "エラーれる次の行" ); } IF(Y < dotList [X]){ projectionMat.put(Y、X、 0 ); のSystem.out.println(X + "列" + Y + "OK" ); } } } 戻りprojectionMatを; }
水平投影
プライベートorg.opencv.core.Mat projectionHorizontal(org.opencv.core.Mat MAT){ org.opencv.core.Mat projectionMat = mat.clone(); // Quxianjiuguoは、MATとして取り込む projectionMat.setTo(新しい新しい ORG .opencv.core.Scalar(255)); // その後白色に入れ ダブル[] = dotList 新しい新しいダブル[mat.rows()]; //は、各列の黒ドットの数を格納するためのリスト作成 システム.loadLibrary(Core.NATIVE_LIBRARY_NAME) のSystem.out.println(mat.dump()); INT COL = mat.cols(); int型の行= mat.rows(); のための(INT Y = 0; Y <行。 Y ++){ dotList [Y] = 0.0 。 用(INT ; X <COL; X = 0のx ++ ){ ダブル BINDATA = mat.get(Y、X)[0 ]; もし(BINDATA == 0){ // 黑色 dotList [Y] ++ ; } } } // 然后生成投影图 ため(INT Y = 0; Y <mat.rows(); Y ++ ){ ため(int型のx = 0; X <mat.cols(); X ++ ){ 試みます{ IF(X < dotList [Y]){ projectionMat.put(Y、X、 0 ); } } キャッチ(例外E){ System.out.printlnは( "の処理:" + Y + "番目、" + X + "列" ); } } } 戻りprojectionMat; }