msaf/algorithms/cnmf/segmenter.py
def processFlat(self):
        """Main process.
        Returns
        -------
        est_idxs : np.array(N)
            Estimated indeces for the segment boundaries in frames.
        est_labels : np.array(N-1)
            Estimated labels for the segments.
        """
        # C-NMF params
        niter = self.config["niters"]  # Iterations for the MF and clustering

        # Preprocess to obtain features, times, and input boundary indeces
        F = self._preprocess()

        # Normalize
        F = U.normalize(F, norm_type=self.config["norm_feats"])

        if F.shape[0] >= self.config["h"]:
            # Median filter
            F = median_filter(F, M=self.config["h"])
            #plt.imshow(F.T, interpolation="nearest", aspect="auto"); plt.show()

            # Find the boundary indices and labels using matrix factorization
            est_idxs, est_labels = get_segmentation(
                F.T, self.config["rank"], self.config["R"],
                self.config["rank_labels"], self.config["R_labels"],
                niter=niter, bound_idxs=self.in_bound_idxs, in_labels=None)

            # Remove empty segments if needed
            est_idxs, est_labels = U.remove_empty_segments(est_idxs, est_labels)
        else:
            # The track is too short. We will only output the first and last
            # time stamps
            if self.in_bound_idxs is None:
                est_idxs = np.array([0, F.shape[0] - 1])
                est_labels = [1]
            else:
                est_idxs = self.in_bound_idxs
                est_labels = [1] * (len(est_idxs) + 1)

        # Make sure that the first and last boundaries are included
        assert est_idxs[0] == 0 and est_idxs[-1] == F.shape[0] - 1

        # Post process estimations
        est_idxs, est_labels = self._postprocess(est_idxs, est_labels)

        return est_idxs, est_labels
def processFlat(self):
        """Main process.
        Returns
        -------
        est_idxs : np.array(N)
            Estimated indeces for the segment boundaries in frames.
        est_labels : np.array(N-1)
            Estimated labels for the segments.
        """
        # C-NMF params
        niter = self.config["niters"]  # Iterations for the MF and clustering

        # Preprocess to obtain features, times, and input boundary indeces
        F = self._preprocess()

        # Normalize
        F = U.normalize(F, norm_type=self.config["norm_feats"])

        if F.shape[0] >= self.config["h"]:
            # Median filter
            F = median_filter(F, M=self.config["h"])
            #plt.imshow(F.T, interpolation="nearest", aspect="auto"); plt.show()

            # Find the boundary indices and labels using matrix factorization
            est_idxs, est_labels = get_segmentation(
                F.T, self.config["rank"], self.config["R"],
                self.config["rank_labels"], self.config["R_labels"],
                niter=niter, bound_idxs=self.in_bound_idxs, in_labels=None)

            # Remove empty segments if needed
            est_idxs, est_labels = U.remove_empty_segments(est_idxs, est_labels)
        else:
            # The track is too short. We will only output the first and last
            # time stamps
            if self.in_bound_idxs is None:
                est_idxs = np.array([0, F.shape[0] - 1])
                est_labels = [1]
            else:
                est_idxs = self.in_bound_idxs
                est_labels = [1] * (len(est_idxs) + 1)

        # Make sure that the first and last boundaries are included
        assert est_idxs[0] == 0 and est_idxs[-1] == F.shape[0] - 1

        # Post process estimations
        est_idxs, est_labels = self._postprocess(est_idxs, est_labels)

        return est_idxs, est_labels
def processFlat ( self ) : # C-NMF params niter = self . config [ "niters" ] # Iterations for the MF and clustering # Preprocess to obtain features, times, and input boundary indeces F = self . _preprocess ( ) # Normalize F = U . normalize ( F , norm_type = self . config [ "norm_feats" ] ) if F . shape [ 0 ] >= self . config [ "h" ] : # Median filter F = median_filter ( F , M = self . config [ "h" ] ) #plt.imshow(F.T, interpolation="nearest", aspect="auto"); plt.show() # Find the boundary indices and labels using matrix factorization est_idxs , est_labels = get_segmentation ( F . T , self . config [ "rank" ] , self . config [ "R" ] , self . config [ "rank_labels" ] , self . config [ "R_labels" ] , niter = niter , bound_idxs = self . in_bound_idxs , in_labels = None ) # Remove empty segments if needed est_idxs , est_labels = U . remove_empty_segments ( est_idxs , est_labels ) else : # The track is too short. We will only output the first and last # time stamps if self . in_bound_idxs is None : est_idxs = np . array ( [ 0 , F . shape [ 0 ] - 1 ] ) est_labels = [ 1 ] else : est_idxs = self . in_bound_idxs est_labels = [ 1 ] * ( len ( est_idxs ) + 1 ) # Make sure that the first and last boundaries are included assert est_idxs [ 0 ] == 0 and est_idxs [ - 1 ] == F . shape [ 0 ] - 1 # Post process estimations est_idxs , est_labels = self . _postprocess ( est_idxs , est_labels ) return est_idxs , est_labels
Main process.
        Returns
        -------
        est_idxs : np.array(N)
            Estimated indeces for the segment boundaries in frames.
        est_labels : np.array(N-1)
            Estimated labels for the segments.
Main process . Returns ------- est_idxs : np . array ( N ) Estimated indeces for the segment boundaries in frames . est_labels : np . array ( N - 1 ) Estimated labels for the segments .