Class AlgorithmPowerWatershed

  • All Implemented Interfaces:
    java.awt.event.ActionListener, java.awt.event.WindowListener, java.lang.Runnable, java.util.EventListener

    public class AlgorithmPowerWatershed
    extends AlgorithmBase
    This is a port of C code written by Camille Couprie in 2009. Camille Couprie has kindly granted the NIH MIPAV project permission to port her Power watershed code from C to Java under a BSD license. Porting performed by William Gandler. This "powerwatershed" package provides implementation of several segmentation algorithms on 2D or 3D images. The 3 algorithms are: 1.) Maximum Spanning Forest computed by Kruskal algorithm. 2.) Powerwatersheds (p=infinite, q= 2) : Maximum Spanning Forest computed by Kruskal algorithm and Random walker on plateaus. 3.) Maximum Spanning Forest computed by Prim algorithm using red and black trees. Reference: "Power watersheds: A new image segmentation framework extending graph cuts, random walker and optimal spanning forest" by Camille Couprie, Leo Grady, Laurent Najman, and Hugues Talbot, ICCV'09, 2009,
    • Field Detail

      • Kruskal

        private static int Kruskal
      • PW_qis2

        private static int PW_qis2
      • Prim

        private static int Prim
      • RBT_Black

        private static byte RBT_Black
      • RBT_Red

        private static byte RBT_Red
      • epsilon

        private double epsilon
      • SIZE_MAX_PLATEAU

        private int SIZE_MAX_PLATEAU
      • testRbtInteractive

        private boolean testRbtInteractive
      • testRbtRandom

        private boolean testRbtRandom
      • testIndic

        private boolean testIndic
      • testLifo

        private boolean testLifo
      • algo

        private int algo
      • index_seeds

        private java.util.Vector<java.lang.Integer> index_seeds
      • index_labels

        private java.util.Vector<java.lang.Short> index_labels
      • geod

        private boolean geod
      • produceProbaImage

        private boolean produceProbaImage
      • error

        private boolean error
      • MAX

        private int MAX
      • Indics

        private short[] Indics
    • Constructor Detail

      • AlgorithmPowerWatershed

        public AlgorithmPowerWatershed​(ModelImage destImg,
                                       ModelImage srcImg,
                                       int algo,
                                       java.util.Vector<java.lang.Integer> index_seeds,
                                       java.util.Vector<java.lang.Short> index_labels,
                                       boolean geod)
        Constructs Power watershed algorithm.
        Parameters:
        destImg - Image model where result image is to stored
        srcImg - Source image model
        algo - Kruskal, or Prim
        index_seeds - The index in the image array of the seed
        index_labels - For 2-labels 1 for white foreground and 2 for black background For multi-labels values from 1 to n with n
        geod - Geodesic reconstruction
    • Method Detail

      • finalize

        public void finalize()
        Prepares this class for destruction.
        Overrides:
        finalize in class AlgorithmBase
      • rbtInteractiveTest

        private void rbtInteractiveTest()
      • rbtRandomTest

        private void rbtRandomTest()
      • indicTest

        private void indicTest()
      • lifoTest

        private void lifoTest()
      • PowerWatershed_q2

        private void PowerWatershed_q2​(int[][] edges,
                                       int[] weights,
                                       int[] normal_weights,
                                       int max_weight,
                                       java.util.Vector<java.lang.Integer> seeds,
                                       java.util.Vector<java.lang.Short> labels,
                                       int size_seeds,
                                       int rs,
                                       int cs,
                                       int ds,
                                       int nb_labels,
                                       boolean quicksort,
                                       ModelImage img_proba)
      • RandomWalker

        private boolean RandomWalker​(int[][] index_edges,
                                     int M,
                                     int[] index,
                                     int[] indic_vertex,
                                     int N,
                                     int[] index_seeds,
                                     float[][] boundary_values,
                                     int numb_boundary,
                                     int nb_labels,
                                     float[][] proba)
      • fill_A

        private boolean fill_A​(double[] A_a,
                               int[] A_indc,
                               int[] A_indr,
                               int[] A_nelem,
                               int[] A_m,
                               int[] A_n,
                               int N,
                               int M,
                               int numb_boundary,
                               int[][] index_edges,
                               boolean[] seeded_vertex,
                               int[] indic_sparse,
                               int[] nb_same_edges)
      • fill_B

        private void fill_B​(double[] B_a,
                            int[] B_indc,
                            int[] B_indr,
                            int[] B_nelem,
                            int[] B_m,
                            int[] B_n,
                            int N,
                            int M,
                            int numb_boundary,
                            int[][] index_edges,
                            boolean[] seeded_vertex,
                            int[] indic_sparse,
                            int[] nb_same_edges)
      • TriEdges

        private void TriEdges​(int[][] index_edges,
                              int M,
                              int[] nb_same_edges)
      • TriRapideStochastique

        private void TriRapideStochastique​(int[] A,
                                           int[] I,
                                           int p,
                                           int r)
      • PartitionStochastique

        private int PartitionStochastique​(int[] A,
                                          int[] I,
                                          int p,
                                          int r)
      • Partitionner

        private int Partitionner​(int[] A,
                                 int[] I,
                                 int p,
                                 int r)
      • merge_node

        private void merge_node​(int e1,
                                int e2,
                                int[] Rnk,
                                int[] Fth,
                                float[][] proba,
                                int nb_labels)
      • TriRapideStochastique_dec

        private void TriRapideStochastique_dec​(int[] A,
                                               int[] I,
                                               int p,
                                               int r)
      • PartitionStochastique_dec

        private int PartitionStochastique_dec​(int[] A,
                                              int[] I,
                                              int p,
                                              int r)
      • Partitionner_dec

        private int Partitionner_dec​(int[] A,
                                     int[] I,
                                     int p,
                                     int r)
      • grey_weights_PW

        private int[] grey_weights_PW​(ModelImage image,
                                      int[][] edges,
                                      java.util.Vector<java.lang.Integer> seeds,
                                      int size_seeds,
                                      int[] weights,
                                      boolean quicksort)
      • color_standard_weights_PW

        private int[] color_standard_weights_PW​(ModelImage image,
                                                int[] weights,
                                                int[][] edges,
                                                java.util.Vector<java.lang.Integer> seeds,
                                                int size_seeds,
                                                int[] maxi,
                                                boolean quicksort)
      • MSF_Prim

        private void MSF_Prim​(int[][] edges,
                              int[] weights,
                              java.util.Vector<java.lang.Integer> seeds,
                              java.util.Vector<java.lang.Short> labels,
                              int size_seeds,
                              int rs,
                              int cs,
                              int ds,
                              int nblabels)
      • MSF_Kruskal

        private void MSF_Kruskal​(int[][] edges,
                                 int[] weights,
                                 int max_weight,
                                 java.util.Vector<java.lang.Integer> seeds,
                                 java.util.Vector<java.lang.Short> labels,
                                 int size_seeds,
                                 int rs,
                                 int cs,
                                 int ds,
                                 int nblabels)
      • neighbor

        private int neighbor​(int i,
                             int k,
                             int rs,
                             int cs,
                             int ds)
      • BucketSort

        private void BucketSort​(int[] A,
                                int[] I,
                                int r,
                                int N)
      • element_link

        private int element_link​(int x,
                                 int y,
                                 int[] Rnk,
                                 int[] Fth)
      • grey_weights

        private void grey_weights​(ModelImage image,
                                  int[] weights,
                                  int[][] edges,
                                  java.util.Vector<java.lang.Integer> seeds,
                                  int size_seeds,
                                  boolean geod,
                                  boolean quicksort)
      • compute_edges

        private void compute_edges​(int[][] edges,
                                   int rs,
                                   int cs,
                                   int ds)
      • color_standard_weights

        private int color_standard_weights​(ModelImage image,
                                           int[] weights,
                                           int[][] edges,
                                           java.util.Vector<java.lang.Integer> seeds,
                                           int size_seeds,
                                           boolean geod,
                                           boolean quicksort)
      • neighbor_node_edge

        private int neighbor_node_edge​(int i,
                                       int k,
                                       int rs,
                                       int cs,
                                       int ds)
      • gageodilate_union_find

        private void gageodilate_union_find​(int[] F,
                                            int[] G,
                                            int[] O,
                                            int[][] edges,
                                            int rs,
                                            int cs,
                                            int ds,
                                            int max_weight,
                                            boolean quicksort)
      • element_link_geod_dilate

        private void element_link_geod_dilate​(int n,
                                              int p,
                                              int[] Fth,
                                              int[] G,
                                              int[] O)
      • element_find

        int element_find​(int x,
                         int[] Fth)
      • neighbor_edge_3D

        private int neighbor_edge_3D​(int node1,
                                     int node2,
                                     int i,
                                     int k,
                                     int rs,
                                     int cs,
                                     int ds)
      • neighbor_edge

        private int neighbor_edge​(int i,
                                  int k,
                                  int rs,
                                  int cs,
                                  int ds)
      • TriRapideStochastique_inc

        private void TriRapideStochastique_inc​(int[] A,
                                               int[] I,
                                               int p,
                                               int r)
      • PartitionStochastique_inc

        private int PartitionStochastique_inc​(int[] A,
                                              int[] I,
                                              int p,
                                              int r)
      • Partitionner_inc

        int Partitionner_inc​(int[] A,
                             int[] I,
                             int p,
                             int r)
      • BucketSortCroiss

        private void BucketSortCroiss​(int[] A,
                                      int[] I,
                                      int r,
                                      int N)
      • IndicsInit

        private void IndicsInit​(int Size)
      • Set

        private void Set​(int x,
                         int INDIC)
      • UnSet

        private void UnSet​(int x,
                           int INDIC)
      • IsSet

        private boolean IsSet​(int x,
                              int INDIC)
      • UnSetAll

        private void UnSetAll​(int x)