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

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>
            亚洲欧美成人综合| 蜜臀a∨国产成人精品| 久久精品99无色码中文字幕| 亚洲天堂久久| 午夜激情综合网| 亚洲欧美视频在线观看| 欧美在线免费观看| 久久不见久久见免费视频1| 欧美一区二区三区视频在线观看| 欧美一区二区三区播放老司机| 欧美一区深夜视频| 久久综合狠狠综合久久综青草| 欧美成人一区二免费视频软件| 欧美xxx在线观看| 日韩香蕉视频| 欧美在线视频网站| 欧美国产精品人人做人人爱| 欧美日韩国产精品一区| 欧美日韩亚洲91| 国产精品日韩在线| 在线观看不卡| 午夜精品久久久久久久男人的天堂 | 性欧美暴力猛交69hd| 欧美影院久久久| 欧美搞黄网站| 国产午夜亚洲精品理论片色戒| 亚洲日本在线观看| 久久久久成人精品免费播放动漫| 亚洲精品男同| 亚欧成人在线| 欧美区二区三区| 激情综合视频| 亚洲欧美精品一区| 亚洲高清在线精品| 欧美有码在线观看视频| 欧美日韩一区二区三区在线看| 好吊视频一区二区三区四区| 中文网丁香综合网| 亚洲大胆在线| 久久精品视频免费播放| 国产精品视频大全| 亚洲视频www| 亚洲精品1234| 欧美国产亚洲精品久久久8v| 激情亚洲成人| 久久噜噜亚洲综合| 妖精成人www高清在线观看| 麻豆国产va免费精品高清在线| 国产麻豆精品久久一二三| 久久尤物视频| 国产一区二区成人久久免费影院| 亚洲男人第一av网站| 亚洲精品中文字幕女同| 欧美精品三级日韩久久| 亚洲国产精品久久人人爱蜜臀 | 亚洲国产高清在线| 久久国产精品久久久| 亚洲网站在线播放| 国产精品日韩欧美大师| 欧美一区二区福利在线| 亚洲一区久久久| 国产精品日本| 久久aⅴ国产紧身牛仔裤| 性做久久久久久久免费看| 国产区日韩欧美| 久久婷婷丁香| 久热re这里精品视频在线6| 尤物yw午夜国产精品视频明星| 久久久久国产精品一区三寸| 午夜在线一区| 在线免费观看欧美| 亚洲二区在线观看| 欧美精品www在线观看| 一区二区高清视频在线观看| 99re这里只有精品6| 欧美午夜欧美| 久久成人精品视频| 久久亚洲视频| 亚洲免费观看在线观看| 夜夜嗨av一区二区三区网站四季av| 欧美日韩亚洲成人| 欧美在线观看视频一区二区| 久久成人18免费网站| 亚洲福利在线观看| 亚洲精品在线免费观看视频| 国产精品一区免费在线观看| 久久大逼视频| 免费观看国产成人| 亚洲视频一区二区在线观看| 欧美亚洲一区在线| 亚洲精品美女久久7777777| 亚洲一区区二区| 亚洲国产精品一区二区久| 日韩一区二区精品在线观看| 国产亚洲欧洲| 亚洲精品国产精品乱码不99| 国产精品美女久久久久av超清| 免费一级欧美片在线播放| 欧美日韩综合精品| 嫩草国产精品入口| 国产精品自在线| 亚洲国产毛片完整版| 国产情人节一区| 亚洲精品一区久久久久久| 激情成人在线视频| 99精品福利视频| 亚洲高清av在线| 亚洲欧美在线另类| 欧美日韩ab| 久久色中文字幕| 欧美三区视频| 亚洲第一视频网站| 国产婷婷色一区二区三区在线| 亚洲精品欧洲| 亚洲第一在线视频| 午夜精品一区二区三区电影天堂 | 久久婷婷麻豆| 欧美亚洲一区二区三区| 欧美美女视频| 欧美黑人一区二区三区| 国产亚洲制服色| 亚洲特级毛片| 一区二区三区高清不卡| 麻豆av一区二区三区| 香蕉乱码成人久久天堂爱免费| 欧美精品首页| 亚洲欧洲日韩综合二区| 亚洲大片免费看| 久久久久se| 久久久久国色av免费看影院| 国产精品国产三级国产普通话99| 亚洲人成毛片在线播放| 亚洲国产精品久久| 另类尿喷潮videofree | 国产欧美视频在线观看| 在线视频欧美日韩精品| 亚洲视频中文字幕| 欧美久久成人| 日韩一区二区电影网| 中文在线不卡视频| 国产精品国产三级国产普通话蜜臀| 亚洲美女在线国产| 亚洲无线视频| 国产女优一区| 久久精品国产精品亚洲| 卡通动漫国产精品| 亚洲激情第一页| 欧美日韩国产成人在线观看| 一区二区三区回区在观看免费视频| 亚洲午夜久久久久久尤物| 欧美亚洲第一页| 亚洲在线中文字幕| 久久九九99视频| 亚洲国产欧美一区二区三区同亚洲| 蜜臀av国产精品久久久久| 亚洲国产综合在线| 亚洲午夜精品视频| 国产美女精品视频| 另类尿喷潮videofree| 亚洲精品日韩在线观看| 午夜精品短视频| 国产一区二区三区自拍| 免费精品视频| 亚洲一区二区三区精品视频| 久久久水蜜桃av免费网站| 在线精品福利| 欧美三级电影大全| 性欧美video另类hd性玩具| 欧美激情精品久久久久| 亚洲性色视频| 久久午夜精品一区二区| 欧美激情一区二区三区| 亚洲亚洲精品三区日韩精品在线视频 | 国产一二精品视频| 欧美a级在线| 亚洲一区二区精品在线| 美女视频一区免费观看| 亚洲一区国产一区| 亚洲电影av在线| 国产精品久久久久毛片大屁完整版 | 欧美专区在线播放| 亚洲国产视频一区| 欧美在线视频不卡| 亚洲国产另类久久精品| 国产精品视频一区二区高潮| 欧美 日韩 国产一区二区在线视频| 亚洲色图综合久久| 亚洲成色777777在线观看影院| 欧美一级二级三级蜜桃| 亚洲国产成人91精品| 国产日本亚洲高清| 欧美视频二区36p| 欧美高清视频一区二区三区在线观看| 亚洲精品视频啊美女在线直播| 久久不射网站| 欧美一二三区精品| 亚洲欧美激情视频| av成人黄色| 亚洲精品久久久蜜桃 | 欧美交受高潮1|