其中還包含了在書上出的題目**。有點點亂哈。。。
//這2個影象是用來絕對值求差用的,類似上面的影象,也是有點不一樣的影象,檢測出不同的地方。
//cvshowimage("自適應然後開運算,骨精靈 - adaptive open", pgjladaptivebinarymopopenimage);
//cvwaitkey(10);
}} }
//邊緣檢測
iplimage* pedgesimage = cvcloneimage(pbinaryimage);
cvcanny(pedgesimage, pedgesimage, 150, 100, 3);
if (maxcomp.area > 0)
//霍夫直線變換
cvmemstorage* pmemstorage = cvcreatememstorage();
iplimage* phoughtlineimage = cvcloneimage(pedgesimage);
cvseq* lines = cvhoughlines2(phoughtlineimage, pmemstorage, cv_hough_probabilistic, 1, 5, 20, 50, 10);
for (int i = 0; i < lines->total; ++i)
//霍夫圓變換 - 這下面的**耗時太長了,所以遮蔽掉吧。
// iplimage* phoughtcirclessourceimage = cvcloneimage(psourceimage);
// iplimage* phoughtcirclesimage = cvcloneimage(pgrayscaleimage);
// cvsmooth(phoughtcirclesimage, phoughtcirclesimage, cv_gaussian, 5, 5);
// cvseq* results = cvhoughcircles(phoughtcirclesimage, pmemstorage, cv_hough_gradient, 2, phoughtcirclesimage->width / 10);
// printf("圓個數 %d\n", results->total);
// for (int i = 0; i < results->total; ++i)
//
cvshowimage("二值圖 - binary", pbinaryimage);
cvshowimage("自適應閾值 - adaptive", padaptivebinaryimage);
cvshowimage("腐蝕 - erode", perodeimage);
cvshowimage("膨脹 - dilate", pdilate);
cvshowimage("開運算 - morphology open", popenimage);
cvshowimage("閉運算 - morphology open", pcloseimage);
cvshowimage("形態梯度 - morphology gradient", pgradientimage);
cvshowimage("禮帽 - top hat", ptophatimage);
cvshowimage("黑帽 - black hat", pblackhatimage);
cvshowimage("漫水填充 - flood fill", pfloodfillimage);
cvshowimage("高斯模糊 - gauss smooth", pgaussimage);
cvshowimage("高斯模糊測試 - gauss smooth test 5 x 5", pgausstestimage5x5);
cvshowimage("高斯模糊測試 - gauss smooth test 9 x 9", pgausstestimage9x9);
cvshowimage("求原色差的絕對值 - abs different", pdstdiffimage);
cvshowimage("腐蝕後碰著 - abs different", pcleandiffimage);
cvshowimage("膨脹後腐蝕 - abs different", pdirtydiffimage);
cvshowimage("差值後的絕對值,骨精靈 - abs different", pgjldiffimage);
cvshowimage("閾值二值化過後,骨精靈 - binary", pbinarygjlimage);
cvshowimage("閾值二值化後開運算,骨精靈 - mop open", pgjlbinarymopopenimage);
cvshowimage("自適應閾值,骨精靈 - adaptive", padaptivebinarygjlimage);
cvshowimage("自適應然後開運算,骨精靈 - adaptive open", pgjladaptivebinarymopopenimage);
cvshowimage("邊緣檢測 - canny", pedgesimage);
cvshowimage("霍夫直線變換 - houghlines2", phoughtlineimage);
// cvshowimage("霍夫圓變換 - hought circles", phoughtcirclessourceimage);
cvwaitkey();
return 0;
}
形態學相關
膨脹dilation rectangle circle 對邊界點進行擴充,填充空洞,使邊界向外部擴張的過程。腐蝕erosion rectangle circle 消除物體邊界點,使邊界向內部收縮的過程,把小於結構元素的物體去除掉.開運算opening rectangle circle 篩選 先腐蝕後...
opencv學習 形態學
void cvdilate const cvarr src,cvarr dst,iplconvkernel element null,int iterations 1 void cverode const cvarr src,cvarr dst,iplconvkernel element null,...
opencv 形態學處理
影象形態學中的幾個基本操作 腐蝕 膨脹 開操作 閉操作。1.1 腐蝕 結構a被結構b腐蝕的定義為,a b a b 可以理解為,移動結構b,如果結構b與結構a的交集完全屬於結構a的區域內,則儲存該位置點,所有滿足條件的點構成結構a被結構b腐蝕的結果。1.2 膨脹 結構a被結構b膨脹的定義為,a b a...