コード例 #1
0
ファイル: defiGroup.cpp プロジェクト: li3939108/DEF-Parser
void defiGroup::print(FILE* f) const {
  int i;

  fprintf(f, "Group '%s'\n", name());

  if (hasRegionName()) {
    fprintf(f, "  region name '%s'\n", regionName());
  }

  if (hasRegionBox()) {
    int size = numRects_;
    int* xl = xl_;
    int* yl = yl_;
    int* xh = xh_;
    int* yh = yh_;
    for (i = 0; i < size; i++)
      fprintf(f, "  region box %d,%d %d,%d\n", xl[i], yl[i], xh[i], yh[i]);
  }

  if (hasMaxX()) {
    fprintf(f, "  max x %d\n", maxX());
  }

  if (hasMaxY()) {
    fprintf(f, "  max y %d\n", maxY());
  }

  if (hasPerim()) {
    fprintf(f, "  perim %d\n", perim());
  }

}
コード例 #2
0
ファイル: ActiveContourSeed.cpp プロジェクト: cinquin/parismi
/*!
 * Initialize phi
 */
void ActiveContourSeed::initializePhi(int protobuf_idx, Protobuf *proto) {

	// set resolution
	phi_->setResolution(p_->res_x, p_->res_y, p_->res_z);

	// initialize image
	phi_->resize(_dimx_Rel, _dimy_Rel, _dimz_Rel);

	// get cell centers, previous sparse segmentation from protobuf file
	Array1D<int> xAbs(cb), yAbs(cb), zAbs(cb);
	proto->getSparseSegmentationCoordinates("full", protobuf_idx, &xAbs, &yAbs,
			&zAbs);

	// if previous sparse segmentation is empty, then initialize phi from single point
	if (xAbs.size() == 0) {
		for (int x = 0; x < _dimx_Rel; x++) {
			for (int y = 0; y < _dimy_Rel; y++) {
				for (int z = 0; z < _dimz_Rel; z++) {
					float xRadial = (float) (x - _hszX);
					float yRadial = (float) (y - _hszY);
					float zRadial = (float) (z - _hszZ);
					(*phi_)(x, y, z) = sqrtf(
							xRadial * xRadial + yRadial * yRadial + zRadial
									* zRadial) - p_->r;
				}
			}
		}
		// otherwise, initialize phi using distance transform on previous segmentation
	} else {
		// get previous binary segmentation, store in phi
		for (int p = 0; p < xAbs.size(); p++) {
			int xRel, yRel, zRel;
			absToRel(xRel, yRel, zRel, xAbs(p), yAbs(p), zAbs(p));
			(*phi_)(xRel, yRel, zRel) = 1;
		}

		// get perimeter segmentation and store in phi.  Store original segmentation in temp
		Image3D<float> temp(*phi_);
		perim(phi_, 1);

		// calculate distance transform
		bwdist(phi_);

		// Make distances negative inside the segmentation
		for (int x = 0; x < _dimx_Rel; x++) {
			for (int y = 0; y < _dimy_Rel; y++) {
				for (int z = 0; z < _dimz_Rel; z++) {
					if (temp(x, y, z) > float(BWTHRESH)) {
						(*phi_)(x, y, z) = -(*phi_)(x, y, z);
					}
				}
			}
		}
	}

	updateFullSeg(phi_);
}
コード例 #3
0
ファイル: ActiveContourSeed.cpp プロジェクト: cinquin/parismi
void ActiveContourSeed::getSparseCoordinates_perim(Array1D<int> *xS,
		Array1D<int> *yS, Array1D<int> *zS) {

	// get binary segmentation
	Image3D<float> bw(*phi_);
	for (int x = 0; x < _dimx_Rel; x++) {
		for (int y = 0; y < _dimy_Rel; y++) {
			for (int z = 0; z < _dimz_Rel; z++) {
				if (bw(x, y, z) <= 0) {
					bw(x, y, z) = 1;
				} else {
					bw(x, y, z) = 0;
				}
			}
		}
	}
	perim(&bw, 1);

	// get sparse coordinates
	getSparseCoordinates(xS, yS, zS, &bw);
}