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

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 閱讀(942) 評論(0)  編輯 收藏 引用


只有注冊用戶登錄后才能發表評論。
網站導航: 博客園   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>
            亚洲欧美日韩久久精品 | 欧美一级大片在线免费观看| 欧美一区2区视频在线观看| 99re66热这里只有精品3直播| 欧美精品导航| 亚洲午夜激情免费视频| 亚洲免费成人| 国产伦精品一区二区三区| 欧美日韩国产一区二区三区地区| 亚洲精品国精品久久99热| 亚洲第一在线综合网站| 久久看片网站| 国产精品一区在线观看| 香蕉免费一区二区三区在线观看| 欧美一区高清| 国产精品久久久久久久久久久久久 | 亚洲娇小video精品| 欧美日本国产在线| 亚洲在线电影| 欧美激情在线免费观看| 欧美了一区在线观看| 午夜免费电影一区在线观看| 亚洲激情六月丁香| 欧美午夜在线视频| 亚洲精品视频一区| 亚洲一级片在线观看| 亚洲国产成人精品女人久久久| 亚洲欧美在线高清| 久久综合九色综合欧美狠狠| 国产精品99久久久久久有的能看| 亚洲国产一区二区三区在线播| 欧美综合国产精品久久丁香| 国产精品一级二级三级| 欧美激情亚洲自拍| 国产欧美va欧美不卡在线| 亚洲成色www8888| 国产视频久久久久| 最新亚洲视频| 欧美视频一区在线观看| 一本久久a久久免费精品不卡| 亚洲欧洲av一区二区三区久久| 亚洲国产婷婷综合在线精品| 亚洲在线播放| 国产亚洲一区在线| 一本色道久久88精品综合| 亚洲成人在线视频播放| 亚洲丁香婷深爱综合| 欧美激情视频在线播放| 久久人人看视频| 国产精品美女久久久| 91久久综合亚洲鲁鲁五月天| 欧美日韩裸体免费视频| 欧美福利一区二区| 欧美日韩精品一区二区| 欧美国产精品va在线观看| 欧美黄色一级视频| 欧美国产视频在线| 国产亚洲精品成人av久久ww| 亚洲一区二区在线| 亚洲视频日本| 欧美一级成年大片在线观看| 午夜免费在线观看精品视频| 欧美一区二区三区成人| 先锋资源久久| 国产精品久久一区二区三区| 久色婷婷小香蕉久久| 欧美大片91| 欧美一二三视频| 久久久免费观看视频| 久久久噜噜噜久久中文字幕色伊伊 | 亚洲国产精品高清久久久| 一区二区三区中文在线观看| 久久精品一区二区国产| 亚洲国产欧美日韩| 免费观看日韩| 欧美一区二区网站| 免费观看亚洲视频大全| 欧美黄色一区二区| 亚洲精品一区二| 欧美视频手机在线| 久久视频一区二区| 欧美婷婷久久| 免费人成精品欧美精品| 91久久久久久久久久久久久| 午夜精品国产更新| 久久久噜噜噜久噜久久 | 欧美国产极速在线| 亚洲精品网站在线播放gif| 亚洲深夜激情| 麻豆精品一区二区av白丝在线| 欧美风情在线观看| 夜夜爽99久久国产综合精品女不卡| 欧美午夜精品伦理| 亚洲欧洲精品一区二区精品久久久 | 欧美+亚洲+精品+三区| 欧美一区二区在线免费观看| 国语精品中文字幕| 欧美激情一区二区三区在线| 亚洲一区二区三区午夜| 免费欧美电影| 亚洲第一页在线| 欧美精品九九| 欧美中文字幕在线播放| 亚洲精品久久久蜜桃| 久久爱www.| 99精品国产一区二区青青牛奶| 国产乱子伦一区二区三区国色天香| 久久色在线观看| 久久男人av资源网站| 国产日韩欧美亚洲一区| 欧美不卡在线| 久久久激情视频| 久久综合网色—综合色88| 国产一区亚洲一区| 欧美精品九九| 久久综合给合久久狠狠狠97色69| 一本色道久久综合| 欧美激情久久久| 亚洲精品一区在线| 国语自产在线不卡| 国产精品毛片a∨一区二区三区| 亚洲精品护士| 亚洲免费视频一区二区| 国产精品免费网站在线观看| 亚洲一区二区三区成人在线视频精品 | 亚洲国产日韩精品| 国产美女精品一区二区三区| 欧美日韩国产色视频| 夜夜嗨av一区二区三区四季av | 久久久亚洲国产天美传媒修理工| 99精品国产高清一区二区| 欧美日韩国产首页在线观看| 老巨人导航500精品| 欧美一区国产二区| 欧美一区二区三区的| 亚洲专区国产精品| 蜜桃久久精品乱码一区二区| 91久久精品日日躁夜夜躁欧美| 欧美精品v国产精品v日韩精品| 久久精品在线| 日韩午夜免费视频| 亚洲黑丝在线| 午夜精品亚洲| 午夜视频久久久久久| 国产日韩亚洲欧美| 国产伦精品一区二区三区视频孕妇 | 久久中文字幕导航| 艳妇臀荡乳欲伦亚洲一区| 亚洲经典在线看| 欧美一区二区视频网站| 亚洲成人中文| 国产乱人伦精品一区二区| 国产精品久久久久免费a∨| 国产精品捆绑调教| 国产亚洲福利| 欧美精品自拍偷拍动漫精品| 亚洲欧美变态国产另类| 欧美一区二区免费| 亚洲精品孕妇| 国产精品99久久久久久久久久久久| 久久久国产精品一区| 一本色道久久88精品综合| 亚洲午夜精品一区二区| 亚洲午夜久久久久久久久电影院| 亚洲男女自偷自拍图片另类| 亚洲电影网站| 国产视频一区在线观看| 国产视频一区免费看| 亚洲高清视频在线观看| 国产欧美日韩视频| 影音先锋久久久| 日韩视频免费观看| 午夜精品久久久久| 免费人成网站在线观看欧美高清 | 亚洲欧美网站| 久久影视三级福利片| 亚洲激情第一页| 亚洲欧美在线高清| 免播放器亚洲一区| 国产精品久久久久久久久久尿| 欧美—级高清免费播放| 麻豆国产va免费精品高清在线| 欧美欧美午夜aⅴ在线观看| 看片网站欧美日韩| 久久婷婷人人澡人人喊人人爽| 性xx色xx综合久久久xx| 久久综合电影| 美女免费视频一区| 国产精品嫩草影院一区二区| 欧美日产在线观看| 精品1区2区3区4区| 亚洲国产成人av| 欧美在线日韩| 亚洲精品日韩激情在线电影| 最新日韩av| 久久女同互慰一区二区三区| 国产精品视频福利| 国产日韩欧美一区二区| 在线亚洲免费视频| 欧美www视频|