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

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) 評(píng)論(0)  編輯 收藏 引用


只有注冊(cè)用戶(hù)登錄后才能發(fā)表評(píng)論。
網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問(wèn)   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>
            亚洲小说欧美另类婷婷| 亚洲一区二区免费看| 欧美巨乳在线| 性久久久久久久久| 亚洲精品孕妇| 欧美成人黄色小视频| 欧美一区二区视频观看视频| 亚洲日韩欧美视频| 韩国在线一区| 国产精品久久久久久av福利软件| 久久午夜羞羞影院免费观看| 亚洲影视在线播放| 亚洲精品综合在线| 欧美激情在线狂野欧美精品| 久久久蜜臀国产一区二区| 亚洲五月婷婷| 一区二区三区日韩欧美精品| 亚洲第一精品夜夜躁人人爽| 国产一区二区成人| 国产精品永久免费观看| 欧美日韩久久| 欧美激情成人在线| 免费视频一区| 久久视频这里只有精品| 久久精品日韩一区二区三区| 午夜在线精品偷拍| 亚洲欧美高清| 午夜精品久久99蜜桃的功能介绍| 日韩天堂av| 日韩亚洲视频在线| 日韩亚洲欧美在线观看| 亚洲激情国产精品| 欧美激情亚洲| 亚洲精品1区| 亚洲国产精品一区在线观看不卡 | 99精品热6080yy久久| 老鸭窝亚洲一区二区三区| 欧美一区二区日韩一区二区| 亚洲欧美日韩精品久久奇米色影视| av不卡在线| 亚洲午夜精品久久久久久app| 一区二区不卡在线视频 午夜欧美不卡'| 亚洲国产综合91精品麻豆| 亚洲国产成人不卡| 亚洲国产精品视频一区| 在线视频国产日韩| 亚洲经典视频在线观看| 亚洲激情一区| 一区二区三区 在线观看视频| 亚洲视频欧美视频| 午夜精品久久久久99热蜜桃导演| 欧美亚洲一区在线| 久久亚洲图片| 欧美韩国一区| 亚洲美女网站| 亚洲桃色在线一区| 欧美一区午夜视频在线观看| 免费一级欧美片在线观看| 午夜一区在线| 久久精品视频在线免费观看| 蜜桃av综合| 欧美日韩亚洲高清一区二区| 国产精品美女视频网站| 韩国v欧美v日本v亚洲v| 亚洲国产专区校园欧美| 一区二区三区四区国产| 欧美一区二区在线播放| 久久中文字幕一区二区三区| 亚洲国产精品成人精品 | 亚洲欧美国产高清| 久久精品国产一区二区电影 | 国产麻豆视频精品| 亚洲高清在线播放| 一区二区三区日韩精品| 欧美在线观看视频| 欧美国产日产韩国视频| 一本色道久久综合狠狠躁篇的优点| 性感少妇一区| 欧美电影在线观看完整版| 国产精品伊人日日| 亚洲人成毛片在线播放| 亚洲欧美日韩国产综合| 欧美大片专区| 亚洲午夜一区二区三区| 久久久无码精品亚洲日韩按摩| 欧美日韩成人综合| 韩日欧美一区二区| 亚洲一二三四区| 美女视频黄a大片欧美| aa亚洲婷婷| 久久野战av| 国产精品免费在线| 亚洲精品乱码久久久久| 久久国产欧美精品| 99国产一区| 裸体丰满少妇做受久久99精品| 国产精品无码专区在线观看| 亚洲另类自拍| 久久久人成影片一区二区三区| 亚洲日本无吗高清不卡| 久久久久久久综合日本| 国产精品二区二区三区| 亚洲精品欧美| 久久人人九九| 亚洲欧美资源在线| 欧美三级午夜理伦三级中视频| 亚洲电影激情视频网站| 欧美亚洲综合久久| 日韩亚洲欧美中文三级| 欧美国产日韩免费| 亚洲第一狼人社区| 久久久国产精品亚洲一区 | 亚洲综合国产精品| 亚洲经典在线看| 麻豆freexxxx性91精品| 一色屋精品视频在线看| 久久精品视频在线观看| 亚洲综合首页| 国产精品一区=区| 亚洲一区影院| 99热这里只有成人精品国产| 欧美激情综合在线| 亚洲裸体俱乐部裸体舞表演av| 欧美高清在线一区二区| 久久中文在线| 亚洲狠狠婷婷| 欧美99久久| 久久先锋影音av| 亚洲第一综合天堂另类专| 麻豆国产精品777777在线| 久久精品观看| 红桃视频国产精品| 久久中文久久字幕| 久久婷婷亚洲| 尤物九九久久国产精品的特点 | 国产亚洲欧美另类中文| 欧美一区二区三区视频在线观看| 一区二区欧美精品| 国产精品久久久久99| 亚洲欧美日韩综合一区| 亚洲免费在线观看| 国产欧美精品va在线观看| 欧美亚洲一区| 欧美在线免费| 尤物九九久久国产精品的特点| 欧美大胆人体视频| 欧美福利网址| 亚洲一区免费网站| 亚洲在线视频| 黑人极品videos精品欧美裸| 老巨人导航500精品| 免播放器亚洲| 99国产精品99久久久久久| 99在线精品观看| 国产欧美一区二区精品性色| 久久久国产午夜精品| 久久综合给合久久狠狠狠97色69| 亚洲国产精品久久91精品| 亚洲黄色成人久久久| 欧美日韩一级黄| 欧美专区在线| 久久久久久久久久久久久9999| 亚洲精品三级| 亚洲午夜电影网| 合欧美一区二区三区| 亚洲国产精品尤物yw在线观看| 欧美视频一二三区| 久久久综合视频| 欧美激情片在线观看| 午夜久久久久久| 老司机免费视频久久| 亚洲一区二区欧美日韩| 久久精品国产视频| 99精品国产一区二区青青牛奶| 亚洲视频一二区| 亚洲第一区在线观看| 一卡二卡3卡四卡高清精品视频| 国精品一区二区| 亚洲伦理在线| 国产一区二区你懂的| 亚洲三级影院| 国内外成人免费激情在线视频网站 | 久久久久国产精品www| 久久国产精品亚洲77777| 亚洲国产精品嫩草影院| 亚洲一二三区视频在线观看| 精品999日本| 在线一区观看| 亚洲激情成人网| 午夜视频在线观看一区| 亚洲精品乱码久久久久久蜜桃麻豆 | 精品av久久久久电影| 亚洲乱码视频| 亚洲第一精品福利| 99在线精品视频| 亚洲福利视频一区二区| 亚洲免费视频观看| 99精品久久| 久久久久在线| 欧美在线www|