本文整理汇总了C++中GrayImage::computeCenterOfMassCenteredImage方法的典型用法代码示例。如果您正苦于以下问题:C++ GrayImage::computeCenterOfMassCenteredImage方法的具体用法?C++ GrayImage::computeCenterOfMassCenteredImage怎么用?C++ GrayImage::computeCenterOfMassCenteredImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GrayImage
的用法示例。
在下文中一共展示了GrayImage::computeCenterOfMassCenteredImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
/*static*/ void PreprocessingResults::preprocessGlyph(
const PreprocessingParameters parameters,
const GrayImage<> &src,
GrayImage<> &dst,
bool *whitespace/*=NULL*/
)
{
// std::cout << preprocessedGlyphImage << std::endl;
GrayImage<> tmpImage1 = src;
// dst = src;
if (parameters.binarize) { // binarize image
tmpImage1.binarizeOtsu();
}
if (parameters.invert) { // invert image
tmpImage1.invert();
}
if (parameters.preMedian) { // do pre median filtering
dst = tmpImage1;
ImFi::median(dst, tmpImage1, parameters.preMedianMaskSize);
}
// tmpImage1.show("nachinvert");
double thresh = 0.05;
double pixelDens = tmpImage1.pixelDensity();
bool isWs = false;
if (pixelDens < thresh) { isWs = true; }
if (whitespace != NULL) *whitespace = isWs;
// dst = tmpImage1;
// isWs = makeWhitespaceImageOne(dst, tmpImage1, thresh);
if (!isWs) {
// tmpImage1.show("nachwhitespace");
// std::cout << tmpImage1 << std::endl;
// do size normalization:
dst = tmpImage1;
uint8 padValue = 0;
#if 0
// compute center of mass index:
Index ctrOfMassIndex;
dst.computeCenterOfMassIndex(ctrOfMassIndex, true);
// center image on center of mass:
ImOp::extendToCenter(dst, tmpImage1, ctrOfMassIndex, 0, padValue);
#else
dst.computeCenterOfMassCenteredImage(tmpImage1, padValue);
// tmpImage1.show("nachcenterofmass");
#endif
// std::cout << tmpImage2 << std::endl;
// CV_INTER_NN - nearest-neigbor interpolation,
// CV_INTER_LINEAR - bilinear interpolation (used by default)
// CV_INTER_AREA - resampling using pixel area relation. It is preferred method for image decimation that gives moire-free results. In case of zooming it is similar to CV_INTER_NN method.
// CV_INTER_CUBIC - bicubic interpolation.
tmpImage1.resize(parameters.sizeNormWidth, parameters.sizeNormHeight, CV_INTER_LINEAR);
// tmpImage1.show("nachresize");
// std::cout << tmpImage1 << std::endl;
if (parameters.postMedian) { // do pre median filtering
dst = tmpImage1;
ImFi::median(dst, tmpImage1, parameters.postMedianMaskSize);
}
tmpImage1.binarize();
// tmpImage1.show("nachbinarize");
dst = tmpImage1;
} // end if not whitespace
else {
dst.init(parameters.sizeNormWidth, parameters.sizeNormHeight);
dst.fill(0);
dst(0,0) = 255;
}
return;
} // end preprocessGlyph