【机器学习】改善LBP特征提高SVM的可分性的经验总结(一)
生活随笔
收集整理的這篇文章主要介紹了
【机器学习】改善LBP特征提高SVM的可分性的经验总结(一)
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、等價(jià)模式LBP的最初效果
正樣本2343,負(fù)樣本5883,直接計(jì)算等價(jià)模式LBP特征圖,再使用SVM訓(xùn)練一個(gè)分類器。
CvTermCriteria criteria = cvTermCriteria(CV_TERMCRIT_ITER, 1000, FLT_EPSILON);CvSVMParams param(CvSVM::C_SVC, CvSVM::LINEAR, 0, 0.5, 0, 0.01, 0, 0, 0, criteria);?
2、添加高斯濾波處理
GaussianBlur(inputImg, inputImg, Size(3,3), 0);結(jié)論:加入高斯濾波,由于可去除噪聲干擾;車道線檢出率提高,多檢率降低。
?
3、再把LBP特征計(jì)算的像素差值增大至5?
// LBP特征的實(shí)現(xiàn)及LBP+SVM分類 https://blog.csdn.net/qianqing13579/article/details/49406563 // 計(jì)算等價(jià)模式LBP特征圖,為了方便表示特征圖,58種等價(jià)模式表示為1~58,第59種混合模式表示為0 static void ComputeLBPImage_Uniform(const Mat &srcImage, Mat &LBPImage) {// 參數(shù)檢查,內(nèi)存分配CV_Assert(srcImage.depth() == CV_8U&&srcImage.channels() == 1);LBPImage.create(srcImage.size(), srcImage.type());// 計(jì)算LBP圖// 擴(kuò)充原圖像邊界,便于邊界處理Mat extendedImage;copyMakeBorder(srcImage, extendedImage, 1, 1, 1, 1, BORDER_DEFAULT);// 構(gòu)建LBP 等價(jià)模式查找表//int table[256];//BuildUniformPatternTable(table);// LUT(256種每一種模式對(duì)應(yīng)的等價(jià)模式)static const int table[256] = { 1, 2, 3, 4, 5, 0, 6, 7, 8, 0, 0, 0, 9, 0, 10, 11, 12, 0, 0, 0, 0, 0, 0, 0, 13, 0, 0, 0, 14, 0, 15, 16, 17, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 20, 0, 21, 22, 23, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 25,0, 0, 0, 0, 0, 0, 0, 26, 0, 0, 0, 27, 0, 28, 29, 30, 31, 0, 32, 0, 0, 0, 33, 0, 0, 0, 0, 0, 0, 0, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 36, 37, 38, 0, 39, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 41, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 43, 44, 0, 45, 0, 0, 0, 46, 0, 0, 0, 0, 0, 0, 0, 47, 48, 49, 0, 50, 0, 0, 0, 51, 52, 53, 0, 54, 55, 56, 57, 58 };// 計(jì)算LBPint heightOfExtendedImage = extendedImage.rows;int widthOfExtendedImage = extendedImage.cols;int widthOfLBP=LBPImage.cols;uchar *rowOfExtendedImage = extendedImage.data+widthOfExtendedImage+1;uchar *rowOfLBPImage = LBPImage.data;int pixelDiff = 5;for (int y = 1; y <= heightOfExtendedImage - 2; ++y,rowOfExtendedImage += widthOfExtendedImage, rowOfLBPImage += widthOfLBP){// 列uchar *colOfExtendedImage = rowOfExtendedImage;uchar *colOfLBPImage = rowOfLBPImage;for (int x = 1; x <= widthOfExtendedImage - 2; ++x, ++colOfExtendedImage, ++colOfLBPImage){// 計(jì)算LBP值int LBPValue = 0;if (colOfExtendedImage[0 - widthOfExtendedImage - 1] >= colOfExtendedImage[0]+pixelDiff)LBPValue += 128;if (colOfExtendedImage[0 - widthOfExtendedImage] >= colOfExtendedImage[0]+pixelDiff)LBPValue += 64;if (colOfExtendedImage[0 - widthOfExtendedImage + 1] >= colOfExtendedImage[0]+pixelDiff)LBPValue += 32;if (colOfExtendedImage[0 + 1] >= colOfExtendedImage[0]+pixelDiff)LBPValue += 16;if (colOfExtendedImage[0 + widthOfExtendedImage + 1] >= colOfExtendedImage[0]+pixelDiff)LBPValue += 8;if (colOfExtendedImage[0 + widthOfExtendedImage] >= colOfExtendedImage[0]+pixelDiff)LBPValue += 4;if (colOfExtendedImage[0 + widthOfExtendedImage - 1] >= colOfExtendedImage[0]+pixelDiff)LBPValue += 2;if (colOfExtendedImage[0 - 1] >= colOfExtendedImage[0]+pixelDiff)LBPValue += 1;colOfLBPImage[0] = table[LBPValue];} // x}// y }結(jié)論:計(jì)算LBP編碼值,像素差值取5,可以減少背景細(xì)微差異而又滿足車道線特征分布帶來(lái)的多檢,整體而言檢測(cè)結(jié)果更加準(zhǔn)確。
總結(jié)
以上是生活随笔為你收集整理的【机器学习】改善LBP特征提高SVM的可分性的经验总结(一)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 【机器学习】LBP特征融合最大灰度差、平
- 下一篇: 【机器学习】改善LBP特征提高SVM的可