@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);
  }
  @SuppressWarnings("unchecked")
  private void setLimboDilation(Region<E> reg, CubeHistogram<E> ch) {

    if (reg.getType() == byte.class) {
      final Byte gmin = Byte.valueOf((byte) 0);
      System.out.println("limbo gmin " + (gmin.intValue() & byteMask));
      reg.setLimbo((E) gmin);
      return;
    }
    if (reg.getType() == short.class) {
      final Short gmin = Short.valueOf((short) 0);
      System.out.println("limbo gmin " + (gmin.intValue() & shortMask));
      reg.setLimbo((E) gmin);
      return;
    }
    if (reg.getType() == float.class) {
      Pair<Float, Float> p = (Pair<Float, Float>) ch.getMinMax();
      final Float gmin = p.first;
      System.out.println("limbo gmin " + gmin);
      reg.setLimbo((E) gmin);
      return;
    }
  }