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


C++ MultiArray::subarray方法代码示例

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


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

示例1: poi

std::vector<Shape2> FieldAlgorithms::localizePOIExample(const MultiArray<2, float> &image,  MultiArray<2, RGBValue<UInt8> > &rgb_array)
{
    std::vector<Shape2> pois(30);
    float thld = image[argMax(image)] * 0.2;
    for (int i = 0; i < pois.size(); i++)
    {
        int v1 = std::rand() % image.size() -1;         // v1 in the range 0 to image.size()
        Shape2 poi(image.scanOrderIndexToCoordinate(v1));
        poi = localizeByFollowingLocalMaxima(image, poi);
        if (image[poi] > thld)
        {
            pois[i] = poi;
            MultiArrayView<2, RGBValue<UInt8> > markAsStep(rgb_array.subarray(Shape2(poi[0] - 5, poi[1] -5), Shape2(poi[0] +5, poi[1] +5)));
            for (RGBValue<UInt8> & val : markAsStep)
            {
                val.setRed(200);
            }
        }
        else
        {
            i--;
        }
    }
    return pois;

}
开发者ID:schlesingerphilipp,项目名称:imageProcessing,代码行数:26,代码来源:fieldAlgorithms.cpp

示例2: localizeByFollowingLocalMaxima

Shape2 FieldAlgorithms::localizeByFollowingLocalMaxima(const MultiArray<2, float> &image, Shape2 current)
{

    //Open viewBox of image with center at current
    int upperLeftX = current[0] - ((image.width() / 10) / 2);
    upperLeftX = upperLeftX > -1 ? upperLeftX : 0;
    int upperLeftY = current[1] - ((image.height() / 10) / 2);
    upperLeftY = upperLeftY > -1 ? upperLeftY : 0;
    Shape2 upperLeft(upperLeftX, upperLeftY);
     

    int lowerRightX = current[0] + ((image.width() / 10) / 2);
    lowerRightX = lowerRightX < image.width() ? lowerRightX : image.width() -1;
    int lowerRightY = current[1] + ((image.height() / 10) / 2);
    lowerRightY = lowerRightY < image.height() ? lowerRightY : image.height() -1;
    Shape2 lowerRight(lowerRightX, lowerRightY);
    MultiArrayView<2, float> box = image.subarray(upperLeft, lowerRight);
    //3: get local max of view as next 
    int maxIndex = argMax(box);
    if (maxIndex == -1)
    {
            std::cout << "Something went wrong: argMax returned -1";
        return current;
    }
    Shape2 max(box.scanOrderIndexToCoordinate(maxIndex));
    Shape2 next(upperLeftX + max[0], upperLeftY + max[1]);
    if (next == current)
    {
        return next;
    }
    return localizeByFollowingLocalMaxima(image, next);
}
开发者ID:schlesingerphilipp,项目名称:imageProcessing,代码行数:32,代码来源:fieldAlgorithms.cpp


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