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