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


C++ GrayImage::computeRoiImage方法代码示例

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


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

示例1: calculateOutputDataMatrix

void CharFeatureCollection::calculateOutputDataMatrix(std::vector<ImageChar*> &imageChars)
{
	// check if there are features:
	if (mImageCharFeatureVec.empty()) {
		std::cout << "Exception in CharFeatureCollection::calculateOutputDataMatrix(std::vector<ImageChar> &imageChars): no feature vector list!" << std::endl;
		throw NoDataException("No features specified for feature vector calculation!");
	}

	// calc. size of one column:
	int nCols = 0;
	for (int i=0; i<mImageCharFeatureVec.size(); ++i) {
		nCols += mImageCharFeatureVec[i]->vectorSize();
	}
	// resize output matrix:
	const int nRows = imageChars.size();
	std::cout << "2 matrix dimensions are: " << nRows << " x " << nCols << std::endl;
	mDataMatrix.resize(nRows, nCols);
#if 1 // take preprocessed image from pointer in ImageChar
	#pragma omp parallel for
	for (int i=0; i<nRows; ++i) {
#if 0
		if (imageChars[i]->mPreprocessingResults.isEmpty()) {
			imageChars[i]->mPreprocessingResults
		}

#else
//		GrayImage<> *pPreprImage = imageChars[i]->pPreprImage;
		GrayImage<> *pPreprImage = imageChars[i]->mPreprocessingResults.mpProcessedImage;
		if (!pPreprImage) {
			std::cerr << "Preprocessing image not available while computing features!" << std::endl;
			throw NoDataException("Preprocessing image not available while computing features!");
		}
#endif
		this->calculateOutputDataRow(*pPreprImage, i, mDataMatrix);
		std::cout << "2Computed feature " << i+1 << " of " << nRows << std::endl;
		// store reference to feature vector in ImageChar of mpImageCharsVec:
		imageChars[i]->setFeatureData(&mDataMatrix, i);
	} // end for all rows i
#else // extract bounding box image from ImageChar
	for (int i=0; i<nRows; ++i) {
		GrayImage<> *pImage = imageChars[i]->pImage;
		BoundingBox bbox = imageChars[i]->bBox;
		pImage->setRoi(bbox);
		GrayImage<> charImage;
		pImage->computeRoiImage(charImage);
		pImage->releaseRoi();
//		std::cout << "current row: " << i << std::endl;
		this->calculateOutputDataRow(charImage, i, mDataMatrix);
		// store reference to feature vector in ImageChar of mpImageCharsVec:
		imageChars[i]->setFeatureData(&mDataMatrix, i);
	} // end for all rows i
#endif

	return;
} // end calculateOutputDataMatrix
开发者ID:hashimmoosavi,项目名称:inventory-extraction,代码行数:55,代码来源:CharFeatureCollection.cpp

示例2: computePreprocessings

void PreprocessingResults::computePreprocessings(const PreprocessingParameters parameters, ImageChar *pImageChar)
{
	this->clear();

	// extract glyph from document image:
	GrayImage<> *pImage = pImageChar->pImage;
	BoundingBox bbox = pImageChar->bBox;
	GrayImage<> glyphImage;
	#pragma omp critical // critical region, since a pointer to common images is set
	{
	pImage->setRoi(bbox);
	pImage->computeRoiImage(glyphImage);
	pImage->releaseRoi();
	}

//	printf("Hello World from thread %d\n", omp_get_thread_num());
//	std::cout << bbox << std::endl;

	// 1st: preprocess glyph image:
	mpProcessedImage = new GrayImage<>();
	PreprocessingResults::preprocessGlyph(parameters, glyphImage, *mpProcessedImage, &isWhiteSpace);
//	pImageChar->pPreprImage = mpProcessedImage;
//	std::cout << "finished processing image " << i << std::endl;
//	std::cout << mProcessedImagesVec[i] << std::endl;

	if (isWhiteSpace) { // jump out as this is a whitespace character
		return;
	}

#if 1
	// 2nd: compute integral invariant image:
	int radius = 2; bool oddSize = true;
	Kernel<> mask;
	Kernel<>::createSphereKernel( mask, radius, oddSize );
//	std::cout << mask << std::endl;
	mpIntInvImage = new GrayImage<float>();
	ImageIntegralInvariant::calcIntegralInvariantImage( mask, *mpProcessedImage, *mpIntInvImage );
#endif

#if 1
	// 3rd: compute distance transform of inverted(!) glyph:
	GrayImage<> invPreprocessedGlyphImage = *mpProcessedImage;
	invPreprocessedGlyphImage.invert();
	mpDistTransformImage = new GrayImage<float>();
	ImageFilter::distTransform(invPreprocessedGlyphImage, *mpDistTransformImage);
#endif

	return;
} // end computePreprocessings(ImageChar *pImageChar)
开发者ID:hashimmoosavi,项目名称:inventory-extraction,代码行数:49,代码来源:PreprocessingResults.cpp


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