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


C++ ImageGray::ysize方法代码示例

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


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

示例1: white_neighbors

int white_neighbors(const Pixel &p, const ImageGray<BYTE> &img)
{
    int nn = 0;
    Pixel p1(p.x-1, p.y);
    if (p1.x >= 0 && p1.x < img.xsize() && p1.y >= 0 && p1.y < img.ysize()) {
        if (img.pixel(p1.x, p1.y) == 255)
            nn++;
    } else {
        nn++;
    }

    Pixel p2(p.x+1, p.y);
    if (p2.x >= 0 && p2.x < img.xsize() && p2.y >= 0 && p2.y < img.ysize()) {
        if (img.pixel(p2.x, p2.y) == 255)
            nn++;
    } else {
        nn++;
    }

    Pixel p3(p.x, p.y-1);
    if (p3.x >= 0 && p3.x < img.xsize() && p3.y >= 0 && p3.y < img.ysize()) {
        if (img.pixel(p3.x, p3.y) == 255)
            nn++;
    } else {
        nn++;
    }

    Pixel p4(p.x, p.y+1);
    if (p4.x >= 0 && p4.x < img.xsize() && p4.y >= 0 && p4.y < img.ysize()) {
        if (img.pixel(p4.x, p4.y) == 255)
            nn++;
    } else {
        nn++;
    }

    if (nn > 0) nn = 1;
    return nn;
}
开发者ID:flm8620,项目名称:Calib3DTools,代码行数:38,代码来源:abberation.cpp

示例2: extract_CCStats

void extract_CCStats(std::vector<Pixel> &cc, CCStats &stats, const ImageGray<BYTE> &img)
{
    stats.nPoints = cc.size();
    stats.perimeter = 0;
    double meanX = 0, meanY = 0;
    double minX = img.xsize(), minY = img.ysize(), maxX = 0, maxY = 0;
    for (int i = 0; i < cc.size(); i++) {
        meanX += cc[i].x;
        meanY += cc[i].y;
        if (cc[i].x > maxX) maxX = cc[i].x;
        if (cc[i].x < minX) minX = cc[i].x;
        if (cc[i].y > maxY) maxY = cc[i].y;
        if (cc[i].y < minY) minY = cc[i].y;
        stats.perimeter += white_neighbors(Pixel(cc[i].x, cc[i].y), img);
    }
    stats.centerX = meanX / cc.size();
    stats.centerY = meanY / cc.size();
    stats.radius1 = 0.5 * (maxX - minX);
    stats.radius2 = 0.5 * (maxY - minY);
}
开发者ID:flm8620,项目名称:Calib3DTools,代码行数:20,代码来源:abberation.cpp

示例3: 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


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