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


C++ Array1D::sum方法代码示例

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


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

示例1: rayTraceFiller

/*!
 * Name		  : rayTraceFiller
 * Description: Used to generate rachis segmentation
 * Arguments  : PROTO_INPUT  : protobuf input containing segmented germline
 * 				IMAGE_OUTPUT : float image containing intermediate rachis segmentation.  This
 * 				               image needs to be post-processed (thresholding, throw out
 * 				               unconnected components).
 * Syntax	  : ./segpipeline_FREEBSD 0 0 0 0 0 PROTO_INPUT 0 0 rayTraceFiller 32 IMAGE_OUTPUT 0 0 0 0 0 0 0 0
 * Notes	  : This function has a random component, so you won't get the exact same result every time.
 */
void rayTraceFiller(TextIO* inputText, ImageIO* outputImage,
		CallbackFunctions *cb) {
	log(cb, 4, "Calculating rachis segmentation through ray tracing");

	// generate full segmentation
	Protobuf proto(cb);
	proto.readProto(inputText);
	Image3D<float> *I = new Image3D<float> (cb);
	Array1D<float> color(cb);
	proto.getList("protobuf_index", &color);
	color + 1;
	proto.drawSegmentationImage("full", I, &color);

	// generate points spaced uniformly on a sphere
	double Jiggle = 0.03 / sqrt(double(NUM_UNIFORM_POINTS_ON_SPHERE));
	unsigned int Rounds = 5000;
	points P("default", NUM_UNIFORM_POINTS_ON_SPHERE, Jiggle, Rounds);
	Array1D<float> *xUniformP = new Array1D<float> (cb);
	Array1D<float> *yUniformP = new Array1D<float> (cb);
	Array1D<float> *zUniformP = new Array1D<float> (cb);
	P.report(xUniformP, yUniformP, zUniformP);

	// allocate rayScore.   0 if not yet checked, 1 if collision, 2 if no collision
	int dimx, dimy, dimz;
	I->getDimensions(dimx, dimy, dimz);
	boost::multi_array<unsigned char, 4> *rayScore = new boost::multi_array<
			unsigned char, 4>(
			boost::extents[dimx][dimy][dimz][NUM_UNIFORM_POINTS_ON_SPHERE]);

	// allocate array for progress bar
	Array1D<float> *progress = new Array1D<float> (cb);
	progress->resize(NUM_UNIFORM_POINTS_ON_SPHERE);

	// do ray tracing
	log(cb, 4, "Starting ray tracing");
#if defined USELIBDISPATCH
	dispatch_apply(NUM_UNIFORM_POINTS_ON_SPHERE, dispatch_get_global_queue(0,0), ^(size_t ii) {
#else
	for (int ii = 0; ii < NUM_UNIFORM_POINTS_ON_SPHERE; ii++) {
#endif
		int i = (int) ii;

		// get a discrete line
		int xP = iround(LENGTH_BRESENHAM_LINE * (*xUniformP)(i));
		int yP = iround(LENGTH_BRESENHAM_LINE * (*yUniformP)(i));
		int zP = iround(LENGTH_BRESENHAM_LINE * (*zUniformP)(i));
		Array1D<int> xLine(cb), yLine(cb), zLine(cb);
		bresenhamLine(&xLine, &yLine, &zLine, xP, yP, zP);

		// check if ray hits image boundary for every pixel in the image
		for (int xc = 0; xc < dimx; xc++) {
			for (int yc = 0; yc < dimy; yc++) {
				for (int zc = 0; zc < dimz; zc++) {

					// only do ray tracing if ray has not passed through point previously.
					if ((*rayScore)[xc][yc][zc][i] == 0) {
						// iterate over length of ray
						for (int r = 0; r < yLine.size(); r++) {
							int x = xc + xLine(r), y = yc + yLine(r), z = zc
									+ zLine(r);
							if (x >= 0 & x < dimx & y >= 0 & y < dimy & z >= 0
									& z < dimz) { // check if ray in image boundary
								if ((*I)(x, y, z) > float(BWTHRESH)) { // if collision detected, update collision information for all points on ray
									for (int rr = 0; rr <= r; rr++) {
										int xx = xc + xLine(rr), yy = yc
												+ yLine(rr), zz = zc
												+ zLine(rr);
										(*rayScore)[xx][yy][zz][i] = 1;
									}
									break;
								}
								// else ray has reach image boundary
							} else {
								// update non-collision information on all points on the ray
								for (int rr = 0; rr < r; rr++) {
									int xx = xc + xLine(rr), yy = yc
											+ yLine(rr), zz = zc + zLine(rr);
									(*rayScore)[xx][yy][zz][i] = 2;
								}
								break; // break out of iteration over length of the ray
							}
						} // end iterate over length of ray
					}
				}
			}
		}

		// update progress
		(*progress)(i) = 1;
		int progressOutOf100 = (int) (progress->sum()
//.........这里部分代码省略.........
开发者ID:cinquin,项目名称:parismi,代码行数:101,代码来源:plugin_rayTraceFiller.cpp


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