예제 #1
0
  public void initLineMin(
      Matrix4f kToOrigin,
      Matrix4f kFromOrigin,
      float rigid,
      float dim,
      double[] startPoint,
      double[] pt,
      int ptLength,
      double[] unitDirections,
      double unit_tolerance,
      double fMinDist,
      double bracketA,
      double functionA,
      double bracketB,
      double functionB,
      double bracketC,
      double functionC) {
    m_fUnitTolerance = (float) unit_tolerance;
    m_kToOrigin = convertTo4D(kToOrigin);
    m_kFromOrigin = convertTo4D(kFromOrigin);
    m_fRigid = rigid;
    m_fDim = dim;

    for (int i = 0; i < startPoint.length; i++) {
      m_afStartPoint[i] = (float) startPoint[i];
    }
    for (int i = 0; i < unitDirections.length; i++) {
      m_afUnitDirections[i] = (float) unitDirections[i];
    }
    for (int i = 0; i < pt.length; i++) {
      m_afPt[i] = (float) pt[i];
    }
    m_fPtLength = ptLength;
    m_fMinDist = (float) fMinDist;

    if (m_kImageLineMinDual != null) {
      m_kImageLineMinDual.updateParameters(
          m_kToOrigin,
          m_kFromOrigin,
          m_fRigid,
          m_fDim,
          m_afStartPoint,
          m_afPt,
          m_fPtLength,
          m_afUnitDirections,
          m_fUnitTolerance,
          m_fMinDist);
    }
    if (m_kCalcTransform != null) {
      m_kCalcTransform.updateParameters(
          m_kToOrigin,
          m_kFromOrigin,
          m_fRigid,
          m_fDim,
          m_afStartPoint,
          m_afPt,
          m_fPtLength,
          m_afUnitDirections,
          m_fUnitTolerance,
          m_fMinDist);
    }
    if (m_kImageLineMinPass2a != null) {
      m_kImageLineMinPass2a.setMinDist(m_fMinDist);
    }

    int index = 0;
    m_afBracket[index++] = (float) bracketA;
    m_afBracket[index++] = (float) functionA;
    m_afBracket[index++] = -1f;
    m_afBracket[index++] = 0f;

    m_afBracket[index++] = (float) bracketB;
    m_afBracket[index++] = (float) functionB;
    m_afBracket[index++] = 0f;
    m_afBracket[index++] = 0f;

    m_afBracket[index++] = (float) bracketC;
    m_afBracket[index++] = (float) functionC;
    m_afBracket[index++] = 0f;
    m_afBracket[index++] = 0f;

    if (m_kBracketOut != null) {
      if (m_kBracketOut.GetTarget(0) != null) {
        if (m_kBracketOut.GetTarget(0).GetImage() != null) {
          m_kBracketOut.GetTarget(0).GetImage().SetData(m_afBracket, 1, 3);
          m_kBracketOut.GetTarget(0).Reload(true);
        }
      }
    }
  }
예제 #2
0
  private void calcLineMin() {
    m_kImagePointsDual.DetachAllEffects();
    m_kImagePointsDual.AttachEffect(m_kImageLineMinDual);
    boolean bEarly = false;
    Texture kTarget = null;
    OpenGLFrameBuffer kCurrentBracket = m_kBracketOut;
    OpenGLFrameBuffer kNewBracket = m_kBracketNewOut;
    OpenGLFrameBuffer kTempBracket;
    for (int i = 0; i < 100; i++) {
      m_kCalcTransform.SetTexture(kCurrentBracket.GetTarget(0), 0, 0);
      m_kImageLineMinPass2a.SetTexture(kCurrentBracket.GetTarget(0), 0, 0);

      // 1. Create the transform matrix based on the current bracket.
      m_pkRenderer.Resize(
          m_kTransformOut.GetTarget(0).GetImage().GetBound(0),
          m_kTransformOut.GetTarget(0).GetImage().GetBound(1));
      m_kTransformOut.Enable();
      m_pkRenderer.ClearColorDepth();
      // m_pkRenderer.ClearBuffers();
      m_pkRenderer.Draw(m_kTransformPoints);
      m_kTransformOut.Disable();
      /*
      kTarget = m_kTransformOut.GetTarget(0);
      m_pkRenderer.GetTexImage( kTarget );
      for ( int j = 0; j < kTarget.GetImage().GetFloatData().length; j++ )
      {
          System.err.print( kTarget.GetImage().GetFloatData()[j] + " " );
      }
      System.err.println( " " ); */

      // 1. Render all image points w/LineMin1 shaders
      m_pkRenderer.Resize(
          m_kHistogramOutput.GetTarget(0).GetImage().GetBound(0),
          m_kHistogramOutput.GetTarget(0).GetImage().GetBound(1));
      m_kHistogramOutput.Enable();
      m_pkRenderer.ClearColorDepth();
      // m_pkRenderer.ClearBuffers();
      m_pkRenderer.Draw(m_kImagePointsDual);
      m_kHistogramOutput.Disable();

      // 2. Render Histogram points
      m_pkRenderer.Resize(
          m_kHistogramOutputB.GetTarget(0).GetImage().GetBound(0),
          m_kHistogramOutputB.GetTarget(0).GetImage().GetBound(1));
      m_kHistogramOutputB.Enable();
      m_pkRenderer.ClearColorDepth();
      // m_pkRenderer.ClearBuffers();
      m_pkRenderer.Draw(m_kHistogramPoints2D);
      m_kHistogramOutputB.Disable();

      // 3. Render Entropy points w/LineMin1 shader
      m_pkRenderer.Resize(
          m_kEntropyOut.GetTarget(0).GetImage().GetBound(0),
          m_kEntropyOut.GetTarget(0).GetImage().GetBound(1));
      m_kEntropyOut.Enable();
      m_pkRenderer.ClearColorDepth();
      // m_pkRenderer.ClearBuffers();
      m_pkRenderer.Draw(m_kEntropyPoints2D);
      m_kEntropyOut.Disable();

      // 4. Render bracket points w/LineMin2 shader
      m_kBracketPoints.DetachAllEffects();
      m_kBracketPoints.AttachEffect(m_kImageLineMinPass2a);
      m_pkRenderer.Resize(
          kNewBracket.GetTarget(0).GetImage().GetBound(0),
          kNewBracket.GetTarget(0).GetImage().GetBound(1));
      kNewBracket.Enable();
      m_pkRenderer.ClearColorDepth();
      // m_pkRenderer.ClearBuffers();
      m_pkRenderer.Draw(m_kBracketPoints);
      kNewBracket.Disable();
      kTempBracket = kCurrentBracket;
      kCurrentBracket = kNewBracket;
      kNewBracket = kTempBracket;

      if ((i % 6) == 0) {
        // kTarget = m_kBracketOut.GetTarget(0);
        kTarget = kCurrentBracket.GetTarget(0);
        m_pkRenderer.GetTexImage(kTarget);
        /*
        System.err.println("");
        System.err.println("");
        System.err.println( "GPU BracketA = " + kTarget.GetImage().GetFloatData()[0] + " " + kTarget.GetImage().GetFloatData()[1]);
        System.err.println( "GPU BracketB = " + kTarget.GetImage().GetFloatData()[4] + " " + kTarget.GetImage().GetFloatData()[5]);
        System.err.println( "GPU BracketC = " + kTarget.GetImage().GetFloatData()[8] + " " + kTarget.GetImage().GetFloatData()[9]);
        System.err.println( "   " + i + " xNew = " + kTarget.GetImage().GetFloatData()[3] + " yNew = " +
                kTarget.GetImage().GetFloatData()[6]  + " case: " + kTarget.GetImage().GetFloatData()[7] + " " +
                kTarget.GetImage().GetFloatData()[10] + " " +
                kTarget.GetImage().GetFloatData()[11]);
                */
        if ((Math.abs(kTarget.GetImage().GetFloatData()[8] - kTarget.GetImage().GetFloatData()[0])
            <= m_fUnitTolerance)) {
          m_afBracketB[0] = kTarget.GetImage().GetFloatData()[4];
          m_afBracketB[1] = kTarget.GetImage().GetFloatData()[5];
          bEarly = true;
          break;
        }
        if (kTarget.GetImage().GetFloatData()[3] == 0) {
          m_afBracketB[0] = kTarget.GetImage().GetFloatData()[4];
          m_afBracketB[1] = kTarget.GetImage().GetFloatData()[5];
          bEarly = true;
          System.err.println("BREAK EARLY BAD");
          break;
        }
      }
    }
    if (!bEarly) {
      // kTarget = m_kBracketOut.GetTarget(0);
      kTarget = kCurrentBracket.GetTarget(0);
      m_pkRenderer.GetTexImage(kTarget);
      m_afBracketB[0] = kTarget.GetImage().GetFloatData()[4];
      m_afBracketB[1] = kTarget.GetImage().GetFloatData()[5];
      /*
          System.err.println("");
          System.err.println("");
          System.err.println( "GPU BracketA = " + kTarget.GetImage().GetFloatData()[0] + " " + kTarget.GetImage().GetFloatData()[1]);
          System.err.println( "GPU BracketB = " + kTarget.GetImage().GetFloatData()[4] + " " + kTarget.GetImage().GetFloatData()[5]);
          System.err.println( "GPU BracketC = " + kTarget.GetImage().GetFloatData()[8] + " " + kTarget.GetImage().GetFloatData()[9]);
      */
    }
    // System.err.println( m_afBracketB[0] + " " + m_afBracketB[1] );
  }
예제 #3
0
  public void dispose(GLAutoDrawable arg0) {

    cleanUp();
    if (m_kTextureA != null) {
      m_kTextureA.Release();
      m_kTextureA.GetImage().dispose();
      m_kTextureA.dispose();
      m_kTextureA = null;
    }
    if (m_kTextureB != null) {
      m_kTextureB.Release();
      m_kTextureB.GetImage().dispose();
      m_kTextureB.dispose();
      m_kTextureB = null;
    }

    if (m_kBracketPoints != null) {
      m_pkRenderer.ReleaseResources(m_kBracketPoints);
      m_kBracketPoints.dispose();
      m_kBracketPoints = null;
    }
    if (m_kTransformPoints != null) {
      m_pkRenderer.ReleaseResources(m_kTransformPoints);
      m_kTransformPoints.dispose();
      m_kTransformPoints = null;
    }

    if (m_kImageEffectDual != null) {
      m_pkRenderer.ReleaseResources(m_kImageEffectDual);
      m_kImageEffectDual.dispose();
    }
    if (m_kImageLineMinDual != null) {
      m_pkRenderer.ReleaseResources(m_kImageLineMinDual);
      m_kImageLineMinDual.dispose();
    }
    if (m_kCalcTransform != null) {
      m_pkRenderer.ReleaseResources(m_kCalcTransform);
      m_kCalcTransform.dispose();
    }

    if (m_kBracketOut != null) {
      m_kBracketOut.GetTarget(0).GetImage().dispose();
      m_kBracketOut.GetTarget(0).dispose();
      m_kBracketOut.TerminateBuffer();
      m_kBracketOut.dispose();
    }
    if (m_kTransformOut != null) {
      m_kTransformOut.GetTarget(0).GetImage().dispose();
      m_kTransformOut.GetTarget(0).dispose();
      m_kTransformOut.TerminateBuffer();
      m_kTransformOut.dispose();
    }
    if (m_kBracketNewOut != null) {
      m_kBracketNewOut.GetTarget(0).GetImage().dispose();
      m_kBracketNewOut.GetTarget(0).dispose();
      m_kBracketNewOut.TerminateBuffer();
      m_kBracketNewOut.dispose();
    }

    ImageCatalog.GetActive().dispose();
    VertexProgramCatalog.GetActive().dispose();
    PixelProgramCatalog.GetActive().dispose();
    CompiledProgramCatalog.GetActive().dispose();

    super.dispose();
  }