本文整理汇总了C++中ImageGray::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageGray::size方法的具体用法?C++ ImageGray::size怎么用?C++ ImageGray::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ImageGray
的用法示例。
在下文中一共展示了ImageGray::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: checkSymmetryVertical
double CheckPatterns::checkSymmetryVertical(const ImageGray &sourceImage, bool boundingBox)
{
//bt->reset();
//bt->start();
int numberOfBlackPixels = 0, symmetricBlackPixels = 0;
//double percentageSymmetric;
if (boundingBox)
{
int x1 = this->findLeftBlackPixel(sourceImage);
int x2 = this->findRightBlackPixel(sourceImage);
int y1 = this->findTopBlackPixel(sourceImage);
int y2 = this->findBottomBlackPixel(sourceImage);
for (int y = y2; y >= ((y2 - y1) / 2); y--)
{
for (int x = x2; x >= x1; x--)
{
if (*(sourceImage.data(x, y)) < thresholdValue)
{
numberOfBlackPixels++;
if (*(sourceImage.data(x, sourceImage.height() - y)) < thresholdValue)
{
symmetricBlackPixels++;
}
}
}
}
}
else
{
for (int x = 0; x < sourceImage.width(); x++)
{
auto top_ptr = sourceImage.data(x, 0);
for (int offset = sourceImage.height() - 1; offset > 0; offset -= 2)
{
bool topBlack = *top_ptr < thresholdValue;
bool bottomBlack = *(top_ptr + offset) < thresholdValue;
//numberOfBlackPixels += topBlack;
bool bothBlack = topBlack == bottomBlack;
symmetricBlackPixels += (int)bothBlack;
top_ptr += sourceImage.width();
}
}
}
//percentageSymmetric = ((double)symmetricBlackPixels / (double)numberOfBlackPixels)*100.0;
//bt->stop();
//std::cout << "Time for the checkSymmetryVertical function: " << //bt->elapsedMicroSeconds() << " Microseconds (" << //bt->elapsedMilliSeconds() << "ms)" << std::endl;
//return (int)percentageSymmetric;
return Extensions::getWeightFromPercentage(Extensions::getPercentage(symmetricBlackPixels, sourceImage.size()/2));
}