場景
嘗試通過灰階化和二值化,将車輛的輪廓從道路中分離出來,至少道路和車輛的色塊沒有連通。實際上,沒有達到預定的目标,在處理圖像的過程中,仔細觀察每一個算法處理的細節非常重要
代碼
#include "cv.h"
#include "highgui.h"
#include "opencv2/opencv.hpp"
using namespace cv;
int main() {
cv::Mat srcMat;
srcMat = imread( "D:/20170601092226.png" );
if( !srcMat.data ) return -1;
cvtColor(srcMat, srcMat, CV_BGR2GRAY);
threshold(srcMat, srcMat, 100, 255, CV_THRESH_BINARY);
imshow("threshold", srcMat);
waitKey(0);
return 0;
}
參考
http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/imgproc/threshold/threshold.html
本文轉自fengyuzaitu 51CTO部落格,原文連結:http://blog.51cto.com/fengyuzaitu/1889167,如需轉載請自行聯系原作者