本文整理汇总了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;
}
示例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);
}