青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品

OpenCV detect partial circle with noise

https://stackoverflow.com/questions/26222525/opencv-detect-partial-circle-with-noise

using this as input (your own median filtered image (I've just cropped it):

enter image description here

First I "normalize" the image. I just stretch values, that smallest val is 0 and biggest val is 255, leading to this result: (maybe some real contrast enhancement is better)

enter image description here

after that I compute the threshold of that image with some fixed threshold (you might need to edit that and find a way to choose the threshold dynamically! a better contrast enhancement might help there)

enter image description here

from this image, I use some simple RANSAC circle detection(very similar to my answer in the linked semi-circle detection question), giving you this result as a best semi-sircle:

enter image description here

int main()


{

    //cv::Mat color = cv::imread("../inputData/semi_circle_contrast.png");

    cv::Mat color = cv::imread("../inputData/semi_circle_median.png");

    cv::Mat gray;

 

    // convert to grayscale

    cv::cvtColor(color, gray, CV_BGR2GRAY);

 

    // now map brightest pixel to 255 and smalles pixel val to 0. this is for easier finding of threshold

    double min, max;

    cv::minMaxLoc(gray,&min,&max);

    float sub = min;

    float mult = 255.0f/(float)(max-sub);

    cv::Mat normalized = gray - sub;

    normalized = mult * normalized;

    cv::imshow("normalized" , normalized);

    //--------------------------------

 

 

    // now compute threshold

    // TODO: this might ne a tricky task if noise differs...

    cv::Mat mask;

    //cv::threshold(input, mask, 0, 255, CV_THRESH_BINARY | CV_THRESH_OTSU);

    cv::threshold(normalized, mask, 100, 255, CV_THRESH_BINARY);

 

 

 

    std::vector<cv::Point2f> edgePositions;

    edgePositions = getPointPositions(mask);

 

    // create distance transform to efficiently evaluate distance to nearest edge

    cv::Mat dt;

    cv::distanceTransform(255-mask, dt,CV_DIST_L1, 3);

 

    //TODO: maybe seed random variable for real random numbers.

 

    unsigned int nIterations = 0;

 

    cv::Point2f bestCircleCenter;

    float bestCircleRadius;

    float bestCirclePercentage = 0;

    float minRadius = 50;   // TODO: ADJUST THIS PARAMETER TO YOUR NEEDS, otherwise smaller circles wont be detected or "small noise circles" will have a high percentage of completion

 

    //float minCirclePercentage = 0.2f;

    float minCirclePercentage = 0.05f;  // at least 5% of a circle must be present? maybe more...

 

    int maxNrOfIterations = edgePositions.size();   // TODO: adjust this parameter or include some real ransac criteria with inlier/outlier percentages to decide when to stop

 

    for(unsigned int its=0; its< maxNrOfIterations; ++its)

    {

        //RANSAC: randomly choose 3 point and create a circle:

        //TODO: choose randomly but more intelligent,

        //so that it is more likely to choose three points of a circle.

        //For example if there are many small circles, it is unlikely to randomly choose 3 points of the same circle.

        unsigned int idx1 = rand()%edgePositions.size();

        unsigned int idx2 = rand()%edgePositions.size();

        unsigned int idx3 = rand()%edgePositions.size();

 

        // we need 3 different samples:

        if(idx1 == idx2) continue;

        if(idx1 == idx3) continue;

        if(idx3 == idx2) continue;

 

        // create circle from 3 points:

        cv::Point2f center; float radius;

        getCircle(edgePositions[idx1],edgePositions[idx2],edgePositions[idx3],center,radius);

 

        // inlier set unused at the moment but could be used to approximate a (more robust) circle from alle inlier

        std::vector<cv::Point2f> inlierSet;

 

        //verify or falsify the circle by inlier counting:

        float cPerc = verifyCircle(dt,center,radius, inlierSet);

 

        // update best circle information if necessary

        if(cPerc >= bestCirclePercentage)

            if(radius >= minRadius)

        {

            bestCirclePercentage = cPerc;

            bestCircleRadius = radius;

            bestCircleCenter = center;

        }

 

    }

 

    // draw if good circle was found

    if(bestCirclePercentage >= minCirclePercentage)

        if(bestCircleRadius >= minRadius);

        cv::circle(color, bestCircleCenter,bestCircleRadius, cv::Scalar(255,255,0),1);

 

 

        cv::imshow("output",color);

        cv::imshow("mask",mask);

        cv::waitKey(0);

 

        return 0;

    }

 

float verifyCircle(cv::Mat dt, cv::Point2f center, float radius, std::vector<cv::Point2f> & inlierSet)
{
 unsigned int counter = 0;
 unsigned int inlier = 0;
 float minInlierDist = 2.0f;
 float maxInlierDistMax = 100.0f;
 float maxInlierDist = radius/25.0f;
 if(maxInlierDist<minInlierDist) maxInlierDist = minInlierDist;
 if(maxInlierDist>maxInlierDistMax) maxInlierDist = maxInlierDistMax;
 
 // choose samples along the circle and count inlier percentage
 for(float t =0; t<2*3.14159265359f; t+= 0.05f)
 {
     counter++;
     float cX = radius*cos(t) + center.x;
     float cY = radius*sin(t) + center.y;
 
     if(cX < dt.cols)
     if(cX >= 0)
     if(cY < dt.rows)
     if(cY >= 0)
     if(dt.at<float>(cY,cX) < maxInlierDist)
     {
        inlier++;
        inlierSet.push_back(cv::Point2f(cX,cY));
     }
 }
 
 return (float)inlier/float(counter);
}
 
 
inline void getCircle(cv::Point2f& p1,cv::Point2f& p2,cv::Point2f& p3, cv::Point2f& center, float& radius)
{
  float x1 = p1.x;
  float x2 = p2.x;
  float x3 = p3.x;
 
  float y1 = p1.y;
  float y2 = p2.y;
  float y3 = p3.y;
 
  // PLEASE CHECK FOR TYPOS IN THE FORMULA :)
  center.x = (x1*x1+y1*y1)*(y2-y3) + (x2*x2+y2*y2)*(y3-y1) + (x3*x3+y3*y3)*(y1-y2);
  center.x /= ( 2*(x1*(y2-y3) - y1*(x2-x3) + x2*y3 - x3*y2) );
 
  center.y = (x1*x1 + y1*y1)*(x3-x2) + (x2*x2+y2*y2)*(x1-x3) + (x3*x3 + y3*y3)*(x2-x1);
  center.y /= ( 2*(x1*(y2-y3) - y1*(x2-x3) + x2*y3 - x3*y2) );
 
  radius = sqrt((center.x-x1)*(center.x-x1) + (center.y-y1)*(center.y-y1));
}
 
 
 
std::vector<cv::Point2f> getPointPositions(cv::Mat binaryImage)
{
 std::vector<cv::Point2f> pointPositions;
 
 for(unsigned int y=0; y<binaryImage.rows; ++y)
 {
     //unsigned char* rowPtr = binaryImage.ptr<unsigned char>(y);
     for(unsigned int x=0; x<binaryImage.cols; ++x)
     {
         //if(rowPtr[x] > 0) pointPositions.push_back(cv::Point2i(x,y));
         if(binaryImage.at<unsigned char>(y,x) > 0) pointPositions.push_back(cv::Point2f(x,y));
     }
 }
 
 return pointPositions;
}

 

posted on 2017-10-17 13:39 zmj 閱讀(930) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發(fā)表評論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            欧美另类人妖| 在线观看一区| 欧美在线影院| 午夜精品理论片| 午夜精品久久一牛影视| 亚洲你懂的在线视频| 日韩亚洲一区二区| 日韩视频专区| 午夜精品久久久久| 久久久久**毛片大全| 欧美成年人网| 国产精品欧美在线| 国产一区99| 亚洲成人在线免费| 中国女人久久久| 欧美影片第一页| 老司机午夜精品视频| 亚洲精品婷婷| 午夜欧美大尺度福利影院在线看| 亚洲免费一级电影| 欧美成人情趣视频| 国产日产高清欧美一区二区三区| 亚洲高清久久久| 亚洲宅男天堂在线观看无病毒| 久久人人97超碰人人澡爱香蕉| 亚洲成色最大综合在线| 欧美激情亚洲综合一区| 亚洲丝袜av一区| 蜜月aⅴ免费一区二区三区| 欧美日韩人人澡狠狠躁视频| 韩国av一区二区| 亚洲午夜一区| 亚洲第一在线视频| 久久国产精品99国产精| 欧美日韩精品免费看| 国产自产2019最新不卡| 亚洲无线视频| 亚洲激情网站| 裸体素人女欧美日韩| 国产精品一香蕉国产线看观看 | 欧美大胆a视频| 亚洲天堂偷拍| 欧美日韩一卡二卡| 夜夜嗨av一区二区三区四区| 久久天天综合| 亚洲欧美久久久| 亚洲国产一区二区三区在线播 | 日韩视频不卡中文| 鲁大师成人一区二区三区| 国产欧美日韩视频在线观看 | 日韩午夜av| 欧美激情精品久久久久久黑人| 国产综合色产在线精品| 正在播放欧美一区| 欧美高清视频一区二区三区在线观看| 亚洲欧美综合另类中字| 国产精品国产自产拍高清av王其| 日韩视频不卡中文| 亚洲国产综合在线| 女主播福利一区| 亚洲精品亚洲人成人网| 亚洲福利视频免费观看| 欧美**字幕| 亚洲美女福利视频网站| 亚洲第一精品影视| 欧美高清视频一区二区| 亚洲精品欧美在线| 美女图片一区二区| 欧美aa国产视频| 亚洲精品乱码久久久久久蜜桃麻豆| 欧美jjzz| 欧美日韩日日夜夜| 欧美一区二区视频在线观看| 亚洲一区二区三区精品动漫| 国产日韩精品入口| 欧美a级一区| 欧美精品久久久久久久久老牛影院| 99视频精品在线| 亚洲免费在线| 韩国免费一区| 91久久午夜| 国产精品va在线播放| 欧美一级网站| 久久久久亚洲综合| 亚洲开发第一视频在线播放| 99精品国产在热久久| 国产精品久久久久aaaa| 久久久女女女女999久久| 美女主播一区| 亚洲欧美第一页| 久久精品在线观看| 日韩视频中文字幕| 午夜精品在线| 亚洲欧洲日本mm| 午夜国产一区| 亚洲人成网站影音先锋播放| 一区二区欧美激情| 黄网动漫久久久| 一区二区三区高清在线| 精品999网站| 亚洲国产精品黑人久久久| 91久久午夜| 精品白丝av| 亚洲一区二区三区高清| 亚洲经典一区| 亚洲欧美中文字幕| 亚洲视频精选在线| 久久久久久网| 午夜精品久久久久久久99热浪潮| 久久天堂精品| 久久精品91久久香蕉加勒比 | 老色鬼精品视频在线观看播放| 亚洲小视频在线观看| 美女啪啪无遮挡免费久久网站| 亚洲欧美日韩天堂| 欧美日韩国产123| 欧美激情一区二区三区全黄| 国产情人综合久久777777| 亚洲人永久免费| 在线欧美三区| 久久精品主播| 久久精品国产精品亚洲| 欧美亚男人的天堂| 亚洲欧洲综合另类| 亚洲欧洲日本专区| 久久久久久综合| 久久黄色影院| 国产美女诱惑一区二区| 亚洲毛片播放| 国产精品99久久久久久久久久久久 | 美女诱惑一区| 亚洲第一精品夜夜躁人人躁| 一区二区三区在线视频观看| 亚洲午夜极品| 欧美在线1区| 国产亚洲精品成人av久久ww| 亚洲专区一区| 欧美一区激情| 国产欧美日韩视频一区二区| 亚洲午夜伦理| 久久福利一区| 精品成人乱色一区二区| 久久精品卡一| 欧美国产91| 99精品久久久| 欧美日韩在线三级| 亚洲视频高清| 久久av在线| 精品动漫3d一区二区三区免费版| 久久精品电影| 欧美成人精品在线播放| 亚洲欧洲日本一区二区三区| 男女激情视频一区| 日韩视频―中文字幕| 欧美一级夜夜爽| 在线观看一区| 欧美日韩国产成人在线91| 一本色道久久88综合日韩精品| 亚洲午夜视频在线| 狠狠综合久久| 欧美日韩在线一二三| 久久se精品一区二区| 亚洲高清不卡| 亚洲欧美日韩另类| 亚洲国产成人在线| 一本久久青青| 久久久噜噜噜久噜久久| 亚洲日韩视频| 国产模特精品视频久久久久| 久久精品国产2020观看福利| 亚洲二区视频在线| 欧美一级视频| 一本久久青青| 国产亚洲欧美日韩美女| 欧美福利电影在线观看| 亚洲一区二区三区在线看| 久久亚洲色图| 亚洲视频二区| 狠狠色综合播放一区二区| 欧美色图首页| 能在线观看的日韩av| 午夜在线一区| 亚洲国产中文字幕在线观看| 久久精品官网| 亚洲欧美成人精品| 99综合在线| 在线观看成人一级片| 欧美日韩中文| 欧美喷潮久久久xxxxx| 欧美中文字幕在线观看| 99国产精品久久久| 欧美福利电影在线观看| 久久aⅴ乱码一区二区三区| 亚洲一区二区在线| 亚洲精品之草原avav久久| 国产色综合久久| 国产精品久久午夜夜伦鲁鲁| 欧美高清视频免费观看| 另类激情亚洲| 久久亚洲捆绑美女|