コード例 #1
0
ファイル: ComponentTree.java プロジェクト: Kuboz/mmlib4j
  public void extendedTree(int inf, int sup) {

    long ti = System.currentTimeMillis();
    Queue<NodeCT> fifo = new Queue<NodeCT>();

    for (NodeCT son : this.root.children) {
      fifo.enqueue(son);
    }

    if (isMaxtree && root.level > inf) {
      this.root = getExtendedBranchOfMaxtree(this.root, inf, this.root.level);
    } else if (!isMaxtree && root.level < sup) {
      this.root = getExtendedBranchOfMintree(this.root, sup, this.root.level);
    }

    while (!fifo.isEmpty()) {
      NodeCT no = fifo.dequeue();

      for (NodeCT son : no.children) {
        fifo.enqueue(son);
      }

      if (isMaxtree) {
        getExtendedBranchOfMaxtree(no, no.parent.level + 1, no.level);
      } else {
        getExtendedBranchOfMintree(no, no.parent.level - 1, no.level);
      }
    }
    long tf = System.currentTimeMillis();
    System.out.println("Tempo de execucao [extended tree] " + ((tf - ti) / 1000.0) + "s");
    createNodesMap();
    this.isExtendedTree = true;
  }
コード例 #2
0
ファイル: ComponentTree.java プロジェクト: Kuboz/mmlib4j
 public GrayScaleImage reconstruction(InfoPrunedTree prunedTree) {
   GrayScaleImage imgOut =
       ImageFactory.createGrayScaleImage(
           imgInput.getDepth(), imgInput.getWidth(), imgInput.getHeight());
   Queue<InfoPrunedTree.NodePrunedTree> fifo = new Queue<InfoPrunedTree.NodePrunedTree>();
   fifo.enqueue(prunedTree.getRoot());
   while (!fifo.isEmpty()) {
     InfoPrunedTree.NodePrunedTree node_ = fifo.dequeue();
     NodeCT node = (NodeCT) node_.getInfo();
     for (NodeCT son : node.children) {
       if (prunedTree.wasPruned(son)) {
         for (int p : son.getPixelsOfCC()) {
           imgOut.setPixel(p, node.level);
         }
       }
     }
     for (int p : node.getCanonicalPixels()) {
       imgOut.setPixel(p, node.level);
     }
     for (InfoPrunedTree.NodePrunedTree son : node_.getChildren()) {
       fifo.enqueue(son);
     }
   }
   return imgOut;
 }
コード例 #3
0
ファイル: ComponentTree.java プロジェクト: Kuboz/mmlib4j
 protected void createNodesMap() {
   if (map == null) map = new NodeCT[imgInput.getSize()];
   listNode = new HashSet<NodeCT>();
   listLeaves = new LinkedList<NodeCT>();
   Queue<NodeCT> fifo = new Queue<NodeCT>();
   fifo.enqueue(this.root);
   while (!fifo.isEmpty()) {
     NodeCT no = fifo.dequeue();
     listNode.add(no);
     for (Integer p : no.getCanonicalPixels()) {
       map[p] = no;
     }
     for (NodeCT son : no.children) {
       fifo.enqueue(son);
     }
     if (no.children.isEmpty()) listLeaves.add(no);
   }
 }
コード例 #4
0
ファイル: ComponentTree.java プロジェクト: Kuboz/mmlib4j
  public GrayScaleImage reconstruction() {
    GrayScaleImage imgOut =
        ImageFactory.createGrayScaleImage(
            imgInput.getDepth(), imgInput.getWidth(), imgInput.getHeight());
    Queue<NodeCT> fifo = new Queue<NodeCT>();
    fifo.enqueue(this.root);
    while (!fifo.isEmpty()) {
      NodeCT no = fifo.dequeue();
      for (int p : no.getCanonicalPixels()) {
        imgOut.setPixel(p, no.level);
      }

      for (NodeCT son : no.children) {
        fifo.enqueue(son);
      }
    }
    return imgOut;
  }