資源簡(jiǎn)介
基于VS2015+WIN8通過(guò)opencv實(shí)現(xiàn),圖像中對(duì)象提取,真實(shí)案例,獲取這樣的對(duì)象,去掉其他干擾或非目標(biāo)對(duì)象
代碼片段和文件信息
#include?
#include?
#include?
using?namespace?cv;
using?namespace?std;
Mat?src?binary?dst;
int?main(int?argc?char**?argv)?{
src?=?imread(“D:/gloomyfish/case3.png“?IMREAD_GRAYSCALE);
if?(src.empty())?{
printf(“could?not?load?image...\n“);
return?-1;
}
namedWindow(“input?image“?CV_WINDOW_AUTOSIZE);
imshow(“input?image“?src);
//?二值化
threshold(src?binary?0?255?THRESH_BINARY?|?THRESH_OTSU);
imshow(“binary?image“?binary);
//?形態(tài)學(xué)操作
Mat?kernel?=?getStructuringElement(MORPH_RECT?Size(3?3)?Point(-1?-1));
morphologyEx(binary?dst?MORPH_CLOSE?kernel?Point(-1?-1));
imshow(“close?image“?dst);
kernel?=?getStructuringElement(MORPH_RECT?Size(3?3)?Point(-1?-1));
morphologyEx(dst?dst?MORPH_OPEN?
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件???????2568??2018-01-17?13:52??case3.cpp
?????文件?????617704??2018-01-16?21:49??51CTO-OpenCV小案例實(shí)戰(zhàn)教程-03.pdf
-----------?---------??----------?-----??----
???????????????620272????????????????????2
評(píng)論
共有 條評(píng)論