Exemplo n.º 1
0
  @SuppressWarnings("unchecked")
  @Override
  public Region<E> close(Region<E> reg) {
    // return erode(dilate(reg));

    try {
      CubeHistogram<E> ch = new CubeHistogram<E>((PixelCube<E, BaseIndex>) reg);

      Erosion<E> er = new Erosion<E>((StructureElement<E>) se);

      er.initFunction(ch);

      Dilation<E> dil = new Dilation<E>((StructureElement<E>) se);

      dil.initFunction(ch);

      reg.setIterationPattern(IP_DEFAULT);
      reg.setIndexing(BASE_INDEXING);

      Region<E> out = new Region<E>((PixelCube<E, ?>) reg.clone(), (StructureElement<E>) se);
      // out.setIterationPattern(IP_DEFAULT);
      // out.setIndexing(BASE_INDEXING);

      final ZonalProcessor zp = reg.getProcessor();
      final VectorCube<E> ve = reg.getVectorCube();
      // System.out.println(ve);

      // final double limbodil=0;s
      // Pair<Number,Number> p= (Pair<Number, Number>) ch.getMinMax();
      // final double limboer=p.second.doubleValue();

      Access<E> accessOut = out.getAccess();

      BoundaryCondition<int[]> bc = reg.getBoundaryCondition();

      final int n = (int) accessOut.length();
      int offset = Util.cumprod(se.getDimensions()) + 1; // (int)ve.size();
      System.out.println("offset: " + offset);
      for (int i = 0; i < n + offset; i++) {
        if (i < n) {
          final E elem = zp.elementTransformCond(ve, dil, bc, i);
          accessOut.putE(i, elem);
        }
        if (i >= offset) {
          final int z = i - offset;
          // System.out.println("z: "+ z);
          final E elem = zp.elementTransformCond(ve, er, bc, z);
          accessOut.putE(z, elem);
        }
      }

      // } // end if

      return out;
    } catch (UnsupportedTypeException e) {
      e.printStackTrace();
    }
    return null;
  }
Exemplo n.º 2
0
  @SuppressWarnings("unchecked")
  public MorphoProcessorXD(Region<?> reg) throws UnsupportedTypeException {
    se = new StructureElement<E>((VectorCube<E>) reg.getVectorCube());

    region = reg;
    type = reg.getType();
    CubeHistogram<E> ch = new CubeHistogram<E>((PixelCube<E, ?>) region);
    // System.out.println(ch);
    // System.out.println("min max :"+se.getMinMax());
    se.setMinMax(ch);
    scaled = true;
    // System.out.println("scaling ... \n " +se);
  }
Exemplo n.º 3
0
 public MorphoProcessorXD(StructureElement<?> ase) {
   se = ase;
   type = se.getType();
 }