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


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

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


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

示例1: percentageBlack

double CheckPatterns::percentageBlack(const ImageGray & sourceImage, int xleft, int ytop, int xright, int ybottom)
{
	std::pair<int, int> topleft = {
		Extensions::getValueFromPercentage(sourceImage.width(), xleft),
		Extensions::getValueFromPercentage(sourceImage.height(), ytop),
	};

	std::pair<int, int> bottomright = {
		Extensions::getValueFromPercentage(sourceImage.width(), xright),
		Extensions::getValueFromPercentage(sourceImage.height(), ybottom),
	};

	std::pair<int, int> size = {
		bottomright.first - topleft.first,
		bottomright.second - topleft.second
	};

	unsigned int numBlack = 0;

	auto pxl_ptr = sourceImage.data(topleft.first, topleft.second);

	for (int y = size.second; y > 0; --y) {
		for (int x = size.first; x > 0; --x) {
			numBlack += *pxl_ptr < thresholdValue;
			pxl_ptr++;
		}
		pxl_ptr = sourceImage.data(topleft.first, topleft.second + y);
	}

	return Extensions::getWeightFromPercentage(Extensions::getPercentage(numBlack, size.first * size.second));
}
开发者ID:madmilla,项目名称:Lazaretto,代码行数:31,代码来源:CheckPatterns.cpp

示例2: countBlackPixelsPerLineVertical

double CheckPatterns::countBlackPixelsPerLineVertical(const ImageGray &sourceImage, int percentage)
{
	//bt->reset();
	//bt->start();

	if (percentage > 100)
	{
		percentage = 100;
	}
	else if (percentage < 0)
	{
		percentage = 0;
	}

	//int x = (int)(sourceImage.width() / 100.0 * percentage);
	int x = Extensions::getValueFromPercentage(sourceImage.width(), percentage);
	int blackPixels = 0;

	auto end_ptr = sourceImage.data(x, sourceImage.height());

	for (auto pxl_ptr = sourceImage.data(x, 0); pxl_ptr < end_ptr; pxl_ptr += sourceImage.width())
	{
		blackPixels += (int)(*pxl_ptr < thresholdValue);
	}

	//bt->stop();
	//std::cout << "Time for the countBlackPixelsPerLineVertical function: " << //bt->elapsedMicroSeconds() << " Microseconds (" << //bt->elapsedMilliSeconds() << "ms)" << std::endl;

	//return blackPixels;
	//return (int)(blackPixels / (double)(sourceImage.height()) * 100);
	return Extensions::getWeightFromPercentage(Extensions::getPercentage(blackPixels, sourceImage.height()));
}
开发者ID:madmilla,项目名称:Lazaretto,代码行数:32,代码来源:CheckPatterns.cpp

示例3: countBlackWhiteTransisitionVertical

double CheckPatterns::countBlackWhiteTransisitionVertical(const ImageGray &sourceImage, int percentage)
{
	//bt->reset();
	//bt->start();
	int x = Extensions::getValueFromPercentage(sourceImage.width(), percentage);
	int pixelCounter = 0;
	// set oldpixel to 1 because white is 1 and every ImageGray starts with white
	int oldPixel = 1;

	auto end_ptr = sourceImage.data(x, sourceImage.height());

	bool oldpixel = 1;

	for (auto pxl_ptr = sourceImage.data(x, 0); pxl_ptr < end_ptr; pxl_ptr += sourceImage.width()) {
		bool currentPixel = (*pxl_ptr > thresholdValue);

		pixelCounter += (int)(currentPixel != oldPixel);
		oldPixel = currentPixel;
	}

	//bt->stop();
	//std::cout << "Time for the checkBlackWhiteTransision function: " << //bt->elapsedMicroSeconds() << " Microseconds (" << //bt->elapsedMilliSeconds() << "ms)" << std::endl;
	//return pixelCounter;
	return Extensions::getWeightFromPercentage(Extensions::getPercentage(pixelCounter, sourceImage.height()));
}
开发者ID:madmilla,项目名称:Lazaretto,代码行数:25,代码来源:CheckPatterns.cpp

示例4: 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));
}
开发者ID:madmilla,项目名称:Lazaretto,代码行数:51,代码来源:CheckPatterns.cpp

示例5: findBottomBlackPixel

int CheckPatterns::findBottomBlackPixel(const ImageGray &sourceImage)
{
	int yValue = 0;
	for (int x = sourceImage.width(); x >= 0; x--)
	{
		for (int y = sourceImage.height(); y >= (sourceImage.height() / 2); y--)
		{
			if (*(sourceImage.data(x, y)) < thresholdValue)
			{
				if (y >= yValue)
				{
					yValue = y;
					x--;
					y = 0;
				}
			}
		}
	}
	return yValue;
};
开发者ID:madmilla,项目名称:Lazaretto,代码行数:20,代码来源:CheckPatterns.cpp

示例6: firstEdgeLocationBottom

double CheckPatterns::firstEdgeLocationBottom(const ImageGray & sourceImage, int percentage)
{
	int x = Extensions::getValueFromPercentage(sourceImage.width(), percentage);
	// set oldpixel to 1 because white is 1 and every ImageGray starts with white
	auto end_ptr = sourceImage.data(x, 0);

	bool oldpixel = 1;
	int y = sourceImage.height() - 1;

	for (auto pxl_ptr = sourceImage.data(x, sourceImage.height() - 1); pxl_ptr >= end_ptr; pxl_ptr -= sourceImage.width()) {
		bool currentPixel = (*pxl_ptr > thresholdValue);

		if (oldpixel != currentPixel) {
			return Extensions::getWeightFromPercentage(Extensions::getPercentage(y, sourceImage.height()));
		}

		oldpixel = currentPixel;
		y--;
	}

	return 1.0;
}
开发者ID:madmilla,项目名称:Lazaretto,代码行数:22,代码来源:CheckPatterns.cpp

示例7: findLeftBlackPixel

int CheckPatterns::findLeftBlackPixel(const ImageGray &sourceImage)
{
	int xValue = sourceImage.width();
	for (int y = sourceImage.height(); y >= 0; y--)
	{
		for (int x = 0; x <= (sourceImage.width() / 2); x++)
		{
			if (*(sourceImage.data(x, y)) < thresholdValue)
			{
				if (x <= xValue){
					xValue = x;
					x = 0;
					y--;
				}
			}
		}
	}
	return xValue;
}
开发者ID:madmilla,项目名称:Lazaretto,代码行数:19,代码来源:CheckPatterns.cpp

示例8: saveImg

	void saveImg(const ImageGray & img, const std::string filename)
	{
		CImg<unsigned char> cimg(img.data(), img.width(), img.height(), 1, 1);

		cimg.save(filename.c_str());
	}
开发者ID:ngf-koster,项目名称:THO7-OCR-Team2,代码行数:6,代码来源:ImageLoader.cpp


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