Exemplo n.º 1
0
  private synchronized void initProjectionMatrix(int projectionNumber) {
    // load projection Matrix for current Projection.
    SimpleMatrix pMat = getGeometry().getProjectionMatrix(projectionNumber).computeP();

    float[] pMatFloat = new float[pMat.getCols() * pMat.getRows()];
    for (int j = 0; j < pMat.getRows(); j++) {
      for (int i = 0; i < pMat.getCols(); i++) {
        pMatFloat[(j * pMat.getCols()) + i] = (float) pMat.getElement(j, i);
      }
    }
    JCudaDriver.cuMemcpyHtoD(
        projectionMatrix, Pointer.to(pMatFloat), Sizeof.FLOAT * pMatFloat.length);
  }
Exemplo n.º 2
0
  /**
   * Creates the meshes of one single phase and adds it to the ArrayList of 4D meshes.
   *
   * @param phase
   * @param parameters
   * @param info
   * @param splines
   */
  private void createPhantom(
      int phase, double[] parameters, CONRADCardiacModelConfig info, ArrayList<Mesh4D> splines) {
    String pcaFile = heartBase + "\\CardiacModel\\phase_" + phase + ".ccm";
    ActiveShapeModel asm = new ActiveShapeModel(pcaFile);
    Mesh allComp = asm.getModel(parameters);

    if (phase == 0) {
      for (int i = 0; i < info.numAnatComp; i++) {
        splines.add(new Mesh4D());
      }
    }

    int count = 0;
    for (heartComponents hc : heartComponents.values()) {
      Mesh comp = new Mesh();
      SimpleMatrix pts =
          allComp
              .getPoints()
              .getSubMatrix(info.vertexOffs[count], 0, hc.getNumVertices(), info.vertexDim);
      // rotate and translate points
      for (int i = 0; i < pts.getRows(); i++) {
        SimpleVector row = SimpleOperators.multiply(rot, pts.getRow(i));
        row.add(trans);
        pts.setRowValue(i, row);
      }
      comp.setPoints(pts);
      comp.setConnectivity(
          allComp
              .getConnectivity()
              .getSubMatrix(info.triangleOffs[count], 0, hc.getNumTriangles(), 3));
      splines.get(count).addMesh(comp);
      count++;
    }
  }
Exemplo n.º 3
0
  private void CreatePhantom() {

    // Iterate over all pixels and sum up intensity values of all corresponding ellipses
    double sizeX = (double) super.getSize()[0];
    double sizeY = (double) super.getSize()[1];

    for (int i = 0; i < super.getSize()[0]; ++i) {
      double x = ((double) i - (sizeX - 1) / 2.0) / ((sizeX - 1) / 2.0);
      for (int j = 0; j < super.getSize()[1]; ++j) {
        double y = ((double) j - (sizeY - 1) / 2.0) / ((sizeY - 1) / 2.0);
        super.setAtIndex(i, super.getSize()[1] - j - 1, 0.f);
        for (int k = 0; k < Ellipses.getRows(); ++k) {
          // Extract the ellipse properties here
          double xc = x - Ellipses.getElement(k, 3);
          double yc = y - Ellipses.getElement(k, 4);
          double phi = Ellipses.getElement(k, 5) * Math.PI / 180.0;
          double cos = Math.cos(phi);
          double sin = Math.sin(phi);
          double asq = Ellipses.getElement(k, 1) * Ellipses.getElement(k, 1);
          double bsq = Ellipses.getElement(k, 2) * Ellipses.getElement(k, 2);
          double Val = Ellipses.getElement(k, 0);

          // Check if this pixel is part of the ellipse, if yes, add the given intensity value to it
          double help = Math.pow((xc * cos + yc * sin), 2.0);
          double help2 = Math.pow((yc * cos - xc * sin), 2.0);
          if (help / asq + help2 / bsq <= 1.0)
            super.setAtIndex(
                i,
                super.getSize()[1] - j - 1,
                super.getAtIndex(i, super.getSize()[1] - j - 1) + (float) Val);
        }
      }
    }
  }
  private synchronized void initProjectionMatrix(int projectionNumber) {
    // load projection Matrix for current Projection.
    SimpleMatrix pMat = getGeometry().getProjectionMatrix(projectionNumber).computeP();
    float[] pMatFloat = new float[pMat.getCols() * pMat.getRows()];
    for (int j = 0; j < pMat.getRows(); j++) {
      for (int i = 0; i < pMat.getCols(); i++) {

        pMatFloat[(j * pMat.getCols()) + i] = (float) pMat.getElement(j, i);
      }
    }

    // Obtain the global pointer to the view matrix from
    // the module
    if (projectionMatrix == null)
      projectionMatrix = context.createFloatBuffer(pMatFloat.length, Mem.READ_ONLY);

    projectionMatrix.getBuffer().put(pMatFloat);
    projectionMatrix.getBuffer().rewind();
    commandQueue.putWriteBuffer(projectionMatrix, true).finish();
  }
  public static void printSimpleMatrix(SimpleMatrix A) {
    int n = A.getRows();
    int m = A.getCols();

    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        System.out.print(A.getElement(i, j) + "\t");
      }
      System.out.print("\n");
    }
  }