91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

膨脹腐蝕對靜態車輛檢測

發布時間:2020-06-19 22:41:27 來源:網絡 閱讀:650 作者:fengyuzaitu 欄目:編程語言

場景

    前期進行了二值化處理,車輛和道路存在連通區域,實際上,就沒有必要再次進行形態學的算法處理,不過為了練習使用膨脹和腐蝕,并且了解函數的基本使用,還是進行了處理


代碼

#include "cv.h"

#include "highgui.h"

#include "opencv2/opencv.hpp"


using namespace cv;


Mat srcMat, erosion_dst, dilation_dst;


int erosion_elem = 0;

int erosion_size = 0;

int dilation_elem = 0;

int dilation_size = 0;

int const max_elem = 2;

int const max_kernel_size = 21;



void Erosion( int, void* );

void Dilation( int, void* );


void Erosion( int, void* )

{

  int erosion_type;

  if( erosion_elem == 0 ){ erosion_type = MORPH_RECT; }

  else if( erosion_elem == 1 ){ erosion_type = MORPH_CROSS; }

  else if( erosion_elem == 2) { erosion_type = MORPH_ELLIPSE; }


  Mat element = getStructuringElement( erosion_type,

    Size( 2*erosion_size + 1, 2*erosion_size+1 ),

    Point( erosion_size, erosion_size ) );


  /// 腐蝕操作

  erode( srcMat, erosion_dst, element );

  imshow( "Erosion Demo", erosion_dst );

}



void Dilation( int, void* )

{

  int dilation_type;

  if( dilation_elem == 0 ){ dilation_type = MORPH_RECT; }

  else if( dilation_elem == 1 ){ dilation_type = MORPH_CROSS; }

  else if( dilation_elem == 2) { dilation_type = MORPH_ELLIPSE; }


  Mat element = getStructuringElement( dilation_type,

    Size( 2*dilation_size + 1, 2*dilation_size+1 ),

    Point( dilation_size, dilation_size ) );

  ///膨脹操作

  dilate( srcMat, dilation_dst, element );

  imshow( "Dilation Demo", dilation_dst );

}


int main() {

  srcMat = imread( "D:/20170601092226.png" );


  if( !srcMat.data ) return -1;


  cvtColor(srcMat, srcMat, CV_BGR2GRAY);

  threshold(srcMat, srcMat, 100, 255, CV_THRESH_BINARY);


  namedWindow( "Erosion Demo", CV_WINDOW_AUTOSIZE );

  namedWindow( "Dilation Demo", CV_WINDOW_AUTOSIZE );

  cvMoveWindow( "Dilation Demo", srcMat.cols, 0 );


  /// 創建腐蝕 Trackbar

  createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Erosion Demo",

    &erosion_elem, max_elem,

    Erosion );


  createTrackbar( "Kernel size:\n 2n +1", "Erosion Demo",

    &erosion_size, max_kernel_size,

    Erosion );


  /// 創建膨脹 Trackbar

  createTrackbar( "Element:\n 0: Rect \n 1: Cross \n 2: Ellipse", "Dilation Demo",

    &dilation_elem, max_elem,

    Dilation );


  createTrackbar( "Kernel size:\n 2n +1", "Dilation Demo",

    &dilation_size, max_kernel_size,

    Dilation );


  Erosion( 0, 0 );

  Dilation( 0, 0 );


  waitKey(0);

  return 0;


}


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

张家川| 康马县| 周至县| 民和| 阿图什市| 扎赉特旗| 临潭县| 南昌市| 朔州市| 绥阳县| 淮安市| 克拉玛依市| 江阴市| 乌兰浩特市| 河间市| 霍林郭勒市| 比如县| 龙门县| 尚义县| 尼木县| 儋州市| 澄城县| 长葛市| 郎溪县| 闸北区| 城步| 松潘县| 德安县| 沈阳市| 简阳市| 大田县| 宽城| 连平县| 涿州市| 海丰县| 玛纳斯县| 五常市| 宁明县| 山丹县| 海门市| 分宜县|