当前位置: 首页>>代码示例>>C++>>正文


C++ ImageRGB::pixel_R方法代码示例

本文整理汇总了C++中ImageRGB::pixel_R方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageRGB::pixel_R方法的具体用法?C++ ImageRGB::pixel_R怎么用?C++ ImageRGB::pixel_R使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ImageRGB的用法示例。


在下文中一共展示了ImageRGB::pixel_R方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CC

bool CC(std::vector<CCStats> &ccstats, const ImageGray<BYTE> &imgbi, ImageRGB<BYTE> &imgFeedback)
{
    ImageGray<BYTE> img_copy(imgbi);
    std::vector<Pixel> firstPixels;
    double meansize = 0;
    for (int i = 0; i < imgbi.xsize(); i++) {
        for (int j = 0; j < imgbi.ysize(); j++) {
            std::vector<Pixel> ccC;
            CCStats stats;
            int npix = extract_cc_(Pixel(i, j), ccC, img_copy);
            if (npix > 180) {
                extract_CCStats(ccC, stats, imgbi);
                double compactness = 4*PI*stats.nPoints / (stats.perimeter*stats.perimeter);
                // !!compactness < 1.3 is not a good limit! I changed to 1.5 -Leman
                if (std::min(stats.radius1,
                             stats.radius2) > 8 && compactness < 1.5 && compactness > 0.7) {
                    ccstats.push_back(stats);
                    firstPixels.push_back(Pixel(i, j));
                    meansize += stats.nPoints;
                    // draw Feedback
                    for (int k = 0; k < ccC.size(); ++k) {
                        Pixel p = ccC[k];
                        // black means detected
                        imgFeedback.pixel_R(p.x, p.y) = 0;
                        imgFeedback.pixel_G(p.x, p.y) = 0;
                        imgFeedback.pixel_B(p.x, p.y) = 0;
                    }
                } else {
                    // draw Feedback
                    for (int k = 0; k < ccC.size(); ++k) {
                        Pixel p = ccC[k];
                        // red means it's not a circle
                        imgFeedback.pixel_R(p.x, p.y) = 150;
                        imgFeedback.pixel_G(p.x, p.y) = 0;
                        imgFeedback.pixel_B(p.x, p.y) = 0;
                    }
                }
            } else {
                // draw Feedback
                for (int k = 0; k < ccC.size(); ++k) {
                    Pixel p = ccC[k];
                    // green means it's too small
                    imgFeedback.pixel_R(p.x, p.y) = 0;
                    imgFeedback.pixel_G(p.x, p.y) = 150;
                    imgFeedback.pixel_B(p.x, p.y) = 0;
                }
            }
        }
        double percent = ((double)i / (double)imgbi.xsize())*100;
        if (!(i % (int)(0.2*imgbi.xsize()+1)))
            libMsg::cout<<(int)(percent+1)<<'%'<<libMsg::flush;
        else if (!(i % (int)(0.04*imgbi.xsize()+1)))
            libMsg::cout<<'.'<<libMsg::flush;
    }
    libMsg::cout<<libMsg::endl;

    if (ccstats.size() == 0) {
        libMsg::cout<<"Nothing interesting found in this image. Please check.";
        return false;
    }
    // retrieve min_size and max_size to build a size histogram
    int max_val = 0;
    int rad_thre = 7;
    for (int i = 0; i < ccstats.size(); i++) {
        if (ccstats[i].nPoints > max_val)
            max_val = ccstats[i].nPoints;
    }

    std::vector<int> hist(max_val);
    std::vector<std::stack<int> > hist_stack(max_val); // to keep indeces of all the circles for given size
    // run through all the sizes and build frequency histogram
    for (int i = 0; i < ccstats.size(); i++) {
        int val = ccstats[i].nPoints-1;
        hist[val]++;
        hist_stack[val].push(i);
    }

    meansize /= ccstats.size();
    int commonsize = meansize;
    libMsg::cout<<"Average area of region: "<<meansize<<" pixels"<<libMsg::endl;
    libMsg::cout<<"Max area of region: "<<max_val<<" pixels"<<libMsg::endl;
    libMsg::cout<<"Region found before filter: [ "<<ccstats.size()<<" ]"<<libMsg::endl;
    /*
     *  frequency
     *   ^
     *   |
     *   |
     *   |               |
     *   |               | |           larger than zerogap
     *   |               | |           so we ignore A and B
     *   |   <--->  | ||||| |   |    <--------------->
     *   |  A     | | ||||| ||  |   |                 B
     *   ----------------------------------------------------> size
     *   0               ^                                10000
     *                   |
     *              average size
     *   negative   <---- ---->  positive
     *   direction               direction
     */
    // collect the inliers in positive direction from commonsize idx
//.........这里部分代码省略.........
开发者ID:flm8620,项目名称:Calib3DTools,代码行数:101,代码来源:abberation.cpp


注:本文中的ImageRGB::pixel_R方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。