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


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

本文整理汇总了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
开发者ID:hashimmoosavi,项目名称:inventory-extraction,代码行数:77,代码来源:PreprocessingResults.cpp


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