예제 #1
0
    def seq_filters(self):
        """
        
        :return: 
        """
        # Linear delay filter. Builtin filter.
        delay = DelayFilter()

        # The incoming signal is unchanged.
        original = delay(0)

        # The norm of the signal. Builtin filter.
        norm = NormFilter()

        # Abstract sliding window. Builtin filter.
        sw = BaseSWFilter(min_size=2)

        sw_mean = sw | numeric.mean
        # or sw_mean = MeanSWFilter()

        return [
            FilterDescription(
                name='$F_{L_1} = |F_{t}|_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='lightgray',
                    width=3.0,
                ),
                formula=original | norm(l=1),
            ),
            FilterDescription(name='$M_{50} = |\hat{\mu}_{50}(F_{L_1})|$',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='orange',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=50)),
            FilterDescription(name='$M_{100} = |\hat{\mu}_{100}(F_{L_1})|$',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='red',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=100)),
            FilterDescription(name='$M_{200} = |\hat{\mu}_{200}(F_{L_1})|$',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='blue',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=200)),
        ]
예제 #2
0
    def seq_filters(self):
        """

        :return: 
        """

        # Linear delay filter. Builtin filter.
        delay = DelayFilter()

        # The incoming signal is unchanged.
        original = delay(0)

        # Shift signal to one frame. Builtin filter.
        shift = ShiftSWFilter()

        # The difference between neighboring frames.
        diff = original - shift

        # The norm of the signal. Builtin filter.
        norm = NormFilter()

        # Abstract sliding window. Builtin filter.
        sw = BaseSWFilter(min_size=2)

        sw_mean = sw | numeric.mean
        # or sw_mean = MeanSWFilter()

        sw_median = MedianSWFilter(size=10)

        # sw_max = sw | max

        sign_change = SignChangeFilter()

        atan = (diff
                | original * 256.0
                | numeric.math.atan
                | original * 2.0
                | original / numeric.math.pi)

        # or atan = AtanFilter()

        def sw_mean_diff(g, l):
            """
            
            :param g: 
            :param l: 
            :return: 
            """
            return (norm(l=1)
                    | sw_median(s=10)
                    | (sw_mean(s=g) - sw_mean(s=l))
                    | (sign_change * atan))

        # Sequence of voters.
        voters = range(self.VOTER_COUNT)

        # Sequence of sliding window sizes.
        sizes = list(self.VOTER_SIZE * (i + 1) for i in voters)

        # Sequence of votes of different range normalizations.
        sw_mean_diff_seq = tuple(
            sw_mean_diff(g=g_size, l=l_size) for g_size in sizes
            for l_size in sizes if g_size > l_size)

        # fork = ForkFilter()
        #
        # bulk = BulkFilter()

        # Average vote of different range normalizations.
        sw_mean_diff_norm = (original
                             | sum(sw_mean_diff_seq)
                             | original / len(sw_mean_diff_seq))

        #
        # print('sw_mean_diff(25,12) = ', sw_mean_diff_norm)

        return [
            FilterDescription(
                name='$F_{L_1} = |F_{t}|_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='lightgray',
                    width=3.0,
                ),
                formula=norm(l=1),
            ),

            #
            #
            # FilterDescription(
            #     name='$M_{50} = |\hat{\mu}_{50}(F_{L_1})|$',
            #     plot_options=PlotOptions(
            #         style='-',
            #         color='orange',
            #         width=2.0,
            #     ),
            #     formula=norm(l=1) | sw_mean(s=50)
            # ),
            #
            # FilterDescription(
            #     name='$M_{100} = |\hat{\mu}_{100}(F_{L_1})|$',
            #     plot_options=PlotOptions(
            #         style='-',
            #         color='red',
            #         width=2.0,
            #     ),
            #     formula=norm(l=1) | sw_mean(s=100)
            # ),
            #
            # FilterDescription(
            #     name='$M_{200} = |\hat{\mu}_{200}(F_{L_1})|$',
            #     plot_options=PlotOptions(
            #         style='-',
            #         color='blue',
            #         width=2.0,
            #     ),
            #     formula=norm(l=1) | sw_mean(s=200)
            # ),
            #
            #
            # FilterDescription(
            #     name='$|M_{200} - M_{50}| \\to_{\pm} 0$',
            #     plot_options=PlotOptions(
            #         style='--',
            #         color='blue',
            #         width=1.2,
            #     ),
            #     formula=(
            #         norm(l=1)
            #         | (sw_mean(s=200) - sw_mean(s=50))
            #         # | sign_changes
            #         # | abs
            #         # | original * 0.9
            #     )
            # ),
            #
            #
            # FilterDescription(
            #     name='$M_{50} = |\hat{\mu}_{50}(F_{L_1})|$',
            #     plot_options=PlotOptions(
            #         style='-',
            #         color='orange',
            #         width=2.0,
            #     ),
            #     formula=norm(l=1) | sw_mean(s=50)
            # ),
            #
            #
            #
            # FilterDescription(
            #     name='$M_{50} = |\hat{\mu}_{50}(F_{L_1})|$',
            #     plot_options=PlotOptions(
            #         style='-',
            #         color='orange',
            #         width=2.0,
            #     ),
            #     formula=norm(l=1) | sw_mean(s=50)
            # ),
            FilterDescription(name='25',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='orange',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=25)),
            FilterDescription(name='50',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='red',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=50)),
            FilterDescription(name='75',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='green',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=75)),
            FilterDescription(name='100',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='purple',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=100)),
            FilterDescription(name='$A|M_{200} - M_{100}| \\to_{\pm} 0$',
                              plot_options=PlotOptions(
                                  style='--',
                                  color='blue',
                                  width=1.0,
                              ),
                              formula=norm(l=1) | sw_mean_diff_norm
                              # sw_mean_diff(25,12)
                              ),
        ]
예제 #3
0
    def seq_filters(self):
        """
            Returns filter chart options.
    
            What we do:
                1. Declare «builtin» filters.
                2. Build custom filters.
                3. Build target filter.
                4. Plot them with `FilterDescription`
    
            :returns: filter descriptions for rescaling normalization.
            :rtype: list of FilterDescription
        """

        # Linear delay filter. Builtin filter.
        delay = DelayFilter()

        # The incoming signal is unchanged.
        original = delay(0)

        # Shift signal to one frame. Builtin filter.
        shift = ShiftSWFilter()

        # The difference between neighboring frames.
        diff = original - shift

        # The norm of the signal. Builtin filter.
        norm = NormFilter()

        # Threshold filter.
        threshold = original > self.THRESHOLD

        # Abstract sliding window. Builtin filter.
        sw = BaseSWFilter(size=self.SLIDING_WINDOW_SIZE, min_size=2)

        # Sliding window that returns maximum.
        sw_max = sw | max

        # Sliding window that returns minimum.
        sw_min = sw | min

        # Sum of absolute difference filter.
        sad_filter = diff | abs | norm(l=1)

        # Range normalization.
        sw_norm = (original - sw_min) / (sw_max - sw_min)

        # Frame difference rescaling normalization by span.
        rescaling_filter = sad_filter | sw_norm

        return [
            FilterDescription(
                # Original signal.
                name='$F_{L_1} = ||F_{t}||_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='gray',
                    width=3.0,
                ),
                formula=norm(l=1),
            ),
            FilterDescription(
                # Rescaling Normalization by Span.
                name=('$D_{{\,{size},t}} '
                      '= sw\_norm_{{\,{size} }} D_{{t}}$'.format(
                          size=self.SLIDING_WINDOW_SIZE)),
                plot_options=PlotOptions(
                    style='-',
                    color='green',
                    width=1.0,
                ),
                formula=rescaling_filter),
            FilterDescription(
                # Sum of absolute difference filter.
                name='$D_{t} = ||F_{t} - F_{t-1}||_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='blue',
                    width=2.0,
                ),
                formula=sad_filter | norm(l=1)),
            FilterDescription(
                # rescaling filter > threshold.
                name=('$D_{{\,{size},t}}  > T_{{const}} $'.format(
                    size=self.SLIDING_WINDOW_SIZE)),
                plot_options=PlotOptions(
                    style=':',
                    color='teal',
                    width=2.0,
                ),
                formula=rescaling_filter | threshold),
            FilterDescription(
                # The threshold value.
                name=('$T_{{const}} = {} \in (0; 1)$'.format(self.THRESHOLD)),
                plot_options=PlotOptions(
                    style='-',
                    color='black',
                    width=2.0,
                ),
                formula=norm(l=1) | self.THRESHOLD,
            ),
        ]
    def seq_filters(self):
        """
            Returns filter chart options.

            What we do:
                1. Declare «builtin» filters.
                2. Build custom filters.
                3. Build target filter.
                4. Plot them with `FilterDescription`

            :returns: filter descriptions for average normalization.
            :rtype: list of FilterDescription
        """

        # Linear delay filter. Builtin filter.
        delay = DelayFilter()

        # The incoming signal is unchanged.
        original = delay(0)

        # Shift signal to one frame. Builtin filter.
        shift = ShiftSWFilter()

        # The difference between neighboring frames.
        diff = original - shift

        # The norm of the signal. Builtin filter.
        norm = NormFilter()

        # Threshold filter.
        # noinspection PyUnusedLocal
        threshold = original > self.THRESHOLD

        # Sum of absolute difference filter.
        sad_filter = diff | abs | norm(l=1)

        # Abstract sliding window. Builtin filter.
        sw = BaseSWFilter(size=self.SLIDING_WINDOW_SIZE, min_size=2)

        # Sliding window that returns maximum.
        sw_max = sw | max

        # Sliding window that returns minimum.
        sw_min = sw | min

        # Range normalization.
        sw_norm = (original - sw_min) / (sw_max - sw_min)

        # Sequence of voters.
        voters = range(self.VOTER_COUNT)

        # Sequence of sliding window sizes.
        sizes = (self.VOTER_SIZE * (i + 1) for i in voters)

        # Sequence of votes of different range normalizations.
        sw_norm_votes_seq = (sw_norm(size=size) for size in sizes)

        # Average vote of different range normalizations.
        sw_vote_norm = Filter.sum(sw_norm_votes_seq) / self.VOTER_COUNT

        return (
            FilterDescription(
                # Original signal.
                name='$F_{L_1} = ||F_{t}||_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='gray',
                    width=3.0,
                ),
                formula=norm(l=1),
            ),
            FilterDescription(
                # Sum of absolute difference filter.
                name='$D_{t} = ||F_{t} - F_{t-1}||_{L_1}$',
                plot_options=PlotOptions(
                    style=':',
                    color='gray',
                    width=1.0,
                ),
                formula=sad_filter),
            FilterDescription(
                # Rescaling normalization with neighborhood size = 100.
                name=('$D_{{\,{size},t}}'
                      '= sw\_norm_{{\,{size} }} D_{{t}}$'.format(size=100)),
                plot_options=PlotOptions(
                    style='--',
                    color='purple',
                    width=1.0,
                ),
                formula=sad_filter | sw_norm(size=100)),
            FilterDescription(
                # Rescaling normalization with neighborhood size = 200.
                name=('$D_{{\,{size},t}} '
                      '= sw\_norm_{{\,{size} }} D_{{t}}$'.format(size=200)),
                plot_options=PlotOptions(
                    style='-',
                    color='orange',
                    width=1.0,
                ),
                formula=sad_filter | sw_norm(s=200)),
            FilterDescription(
                # Rescaling normalization with neighborhood size = 300.
                name=('$D_{{\,{size},t}} '
                      '= sw\_norm_{{\,{size} }} D_{{t}}$'.format(size=300)),
                plot_options=PlotOptions(
                    style='-',
                    color='violet',
                    width=1.0,
                ),
                formula=sad_filter | sw_norm(s=300)),
            FilterDescription(
                # Rescaling normalization with neighborhood size = 400.
                name=('$D_{{\,{size},t}} '
                      '= sw\_norm_{{\,{size} }} D_{{t}}$'.format(size=400)),
                plot_options=PlotOptions(
                    style='-',
                    color='red',
                    width=1.0,
                ),
                formula=sad_filter | sw_norm(s=400)),
            FilterDescription(
                # Average vote of different range normalizations.
                name=('$V_{{\,{size},v,t}} = '
                      '\sum^{{i=v+1}}_{{i=1}} '
                      '\\frac{{ D_{{\,{size} i,t}} }}{{v}};'
                      ' v = {voter_count}$'.format(
                          size=self.VOTER_SIZE, voter_count=self.VOTER_COUNT)),
                plot_options=PlotOptions(
                    style='-',
                    color='green',
                    width=2.0,
                ),
                formula=sad_filter | sw_vote_norm),
            FilterDescription(
                # The threshold value.
                name=('$T_{{const}} = {} \in (0; 1)$'.format(self.THRESHOLD)),
                plot_options=PlotOptions(
                    style='-',
                    color='black',
                    width=2.0,
                ),
                formula=norm(l=1) | self.THRESHOLD,
            ),
        )
예제 #5
0
    def seq_filters(self):
        """

        :return: 
        """

        # Linear delay filter. Builtin filter.
        delay = DelayFilter()

        # The incoming signal is unchanged.
        original = delay(0)

        # Shift signal to one frame. Builtin filter.
        shift = ShiftSWFilter()

        # The difference between neighboring frames.
        diff = original - shift

        # The norm of the signal. Builtin filter.
        norm = NormFilter()

        # Abstract sliding window. Builtin filter.
        sw = BaseSWFilter(min_size=2)

        # Sum of absolute difference filter.
        sad_filter = original | diff | abs | norm(l=1)

        sw_mean = sw | numeric.mean
        # or sw_mean = MeanSWFilter()

        sw_std = sw | numeric.std

        # or sw_std = StdSWFilter()

        def z_score(size=1):
            """
            
            :param size: 
            :return: 
            """
            return (((original - sw_mean(s=size)) / sw_std(s=size)) /
                    numeric.sqrt(size)
                    | abs)

        def z_test(size=1):
            """
                ...
            """
            estimation = z_score(size)

            return estimation

        # Sequence of voters.
        voters = range(self.VOTER_COUNT)

        # Sequence of sliding window sizes.
        sizes = (self.VOTER_SIZE * (i + 1) for i in voters)

        # Sequence of votes of different sizes.
        z_vote_seq = (z_test(size=size) for size in sizes)

        # Average vote of different sizes.
        z_vote = sum(z_vote_seq) / self.VOTER_COUNT

        return [
            FilterDescription(
                name='$F_{L_1} = ||F_{t}||_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='gray',
                    width=3.0,
                ),
                formula=norm(l=1),
            ),
            FilterDescription(
                # Sum of absolute difference filter.
                name='$D_{t} = ||F_{t} - F_{t-1}||_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='blue',
                    width=2.0,
                ),
                formula=sad_filter),
            FilterDescription(
                name=('$D_{{t}} > E_{{ {size} }}\ (D_{{t}})$'.format(
                    size=100)),
                plot_options=PlotOptions(
                    style='--',
                    color='green',
                    width=1.0,
                ),
                formula=(diff | norm(l=1)
                         | z_test(size=50))),
            FilterDescription(
                name=('$D_{{t}} > E_{{ {size} }}\ (D_{{t}})$'.format(
                    size=200)),
                plot_options=PlotOptions(
                    style='--',
                    color='red',
                    width=1.0,
                ),
                formula=(diff | norm(l=1)
                         | z_test(size=200))),
            FilterDescription(name=('VOTE'),
                              plot_options=PlotOptions(
                                  style='-',
                                  color='red',
                                  width=2.0,
                              ),
                              formula=(diff | norm(l=1)
                                       | z_vote)),
        ]
예제 #6
0
    def seq_filters(self):
        """

        :return: 
        """

        # Linear delay filter. Builtin filter.
        delay = DelayFilter()

        # The incoming signal is unchanged.
        original = delay(0)

        # Shift signal to one frame. Builtin filter.
        shift = ShiftSWFilter()

        # The difference between neighboring frames.
        diff = original - shift

        # The norm of the signal. Builtin filter.
        norm = NormFilter()

        # Abstract sliding window. Builtin filter.
        sw = BaseSWFilter(min_size=2)

        # Sum of absolute difference filter.
        sad_filter = diff | abs | norm(l=1)

        sw_mean = sw | numeric.mean
        # or sw_mean = MeanSWFilter()

        sw_std = sw | numeric.std

        # or sw_std = StdSWFilter()

        def sigma_estimation(sigma=3.0, size=1):
            """

            :param float sigma: 
            :param int size: 
            :return: 
            """
            return sw_mean(s=size) + sigma * sw_std(s=size)

        def sigma_check(**kwargs):
            """
                ...
            """
            return original > sigma_estimation(**kwargs)

        return [
            FilterDescription(
                name='$F_{L_1} = ||F_{t}||_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='gray',
                    width=3.0,
                ),
                formula=norm(l=1),
            ),
            FilterDescription(
                # Sum of absolute difference filter.
                name='$D_{t} = ||F_{t} - F_{t-1}||_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='blue',
                    width=2.0,
                ),
                formula=sad_filter),
            FilterDescription(
                # Estimation for sum of absolute difference
                name=('$E_{{ {size} }}\ (D_{{t}}) = '
                      '\hat{{\mu}}_{{ {size} }}[D_{{t}}] + A \cdot '
                      '\hat{{\sigma}}_{{ {size} }}[D_{{t}}]$'.format(
                          size=100)),
                plot_options=PlotOptions(
                    style='-',
                    color='orange',
                    width=2.0,
                ),
                formula=(sad_filter
                         | sigma_estimation(size=100))),
            FilterDescription(
                # Estimation for sum of absolute difference
                name=('$E_{{ {size} }}\ (D_{{t}}) = '
                      '\hat{{\mu}}_{{ {size} }}[D_{{t}}] + A \cdot '
                      '\hat{{\sigma}}_{{ {size} }}[D_{{t}}]$'.format(
                          size=200)),
                plot_options=PlotOptions(
                    style='-',
                    color='red',
                    width=2.0,
                ),
                formula=(sad_filter
                         | sigma_estimation(size=200))),
            FilterDescription(
                name=('$D_{{t}} > E_{{ {size} }}\ (D_{{t}})$'.format(
                    size=100)),
                plot_options=PlotOptions(
                    style='--',
                    color='green',
                    width=1.0,
                ),
                formula=(sad_filter
                         | sigma_check(size=100))),
            FilterDescription(
                name=('$D_{{t}} > E_{{ {size} }}\ (D_{{t}})$'.format(
                    size=200)),
                plot_options=PlotOptions(style='--',
                                         color='red',
                                         width=1.5,
                                         marker='x'),
                formula=(sad_filter
                         | sigma_check(size=200) * 0.8)),
        ]
예제 #7
0
    def seq_filters(self):
        """
        
        :return: 
        """
        # Linear delay filter. Builtin filter.
        delay = DelayFilter()

        # The incoming signal is unchanged.
        original = delay(0)

        # The norm of the signal. Builtin filter.
        norm = NormFilter()

        # Abstract sliding window. Builtin filter.
        sw = BaseSWFilter(min_size=2)

        sw_mean = sw | numeric.mean
        # or sw_mean = MeanSWFilter()

        sign_change = SignChangeFilter()

        return [
            FilterDescription(
                name='$F_{L_1} = |F_{t}|_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='lightgray',
                    width=3.0,
                ),
                formula=norm(l=1),
            ),
            FilterDescription(name='$M_{50} = |\hat{\mu}_{50}(F_{L_1})|$',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='orange',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=50)),
            FilterDescription(name='$M_{100} = |\hat{\mu}_{100}(F_{L_1})|$',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='red',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=100)),
            FilterDescription(name='$M_{200} = |\hat{\mu}_{200}(F_{L_1})|$',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='blue',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=200)),
            FilterDescription(name='$|M_{100} - M_{50}| \\to_{\pm} 0$',
                              plot_options=PlotOptions(
                                  style=':',
                                  color='purple',
                                  width=1.1,
                              ),
                              formula=(norm(l=1)
                                       | (sw_mean(s=100) - sw_mean(s=50))
                                       | sign_change
                                       | abs
                                       | original * 1)),
            FilterDescription(name='$|M_{200} - M_{50}| \\to_{\pm} 0$',
                              plot_options=PlotOptions(
                                  style='--',
                                  color='blue',
                                  width=1.2,
                              ),
                              formula=(norm(l=1)
                                       | (sw_mean(s=200) - sw_mean(s=50))
                                       | sign_change
                                       | abs
                                       | original * 0.9)),
            FilterDescription(name='$|M_{200} - M_{100}| \\to_{\pm} 0$',
                              plot_options=PlotOptions(
                                  style='-',
                                  marker='x',
                                  color='green',
                                  width=1.3,
                              ),
                              formula=(norm(l=1)
                                       | (sw_mean(s=200) - sw_mean(s=100))
                                       | sign_change
                                       | abs
                                       | original * 0.8))
        ]
예제 #8
0
    def seq_filters(self):
        """

        :return: 
        """

        # Linear delay filter. Builtin filter.
        delay = DelayFilter()

        # The incoming signal is unchanged.
        original = delay(0)

        # Shift signal to one frame. Builtin filter.
        shift = ShiftSWFilter()

        # The difference between neighboring frames.
        diff = original - shift

        # The norm of the signal. Builtin filter.
        norm = NormFilter()

        # Abstract sliding window. Builtin filter.
        sw = BaseSWFilter(min_size=2)

        # Sum of absolute difference filter.
        sad_filter = diff | abs | norm(l=1)

        sw_mean = sw | numeric.mean
        # or sw_mean = MeanSWFilter()

        sw_std = sw | numeric.std

        # or sw_std = StdSWFilter()

        def sigma_estimation(sigma=3.0, size=1):
            """

            :param float sigma: 
            :param int size: 
            :return: 
            """
            return sw_mean(s=size) + sigma * sw_std(s=size)

        def sigma_check(**kwargs):
            """
                ...
            """
            return original > sigma_estimation(**kwargs)

        # Sequence of voters.
        voters = range(self.VOTER_COUNT)

        # Sequence of sliding window sizes.
        sizes = (self.VOTER_SIZE * (i + 1) for i in voters)

        # Sequence of votes of different sizes.
        sigma_vote_seq = (sigma_check(size=size) for size in sizes)

        # Average vote of different sizes.
        sigma_vote = sum(sigma_vote_seq) / self.VOTER_COUNT

        return [
            FilterDescription(
                name='$F_{L_1} = ||F_{t}||_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='gray',
                    width=3.0,
                ),
                formula=norm(l=1),
            ),
            FilterDescription(
                # Sum of absolute difference filter.
                name='$D_{t} = ||F_{t} - F_{t-1}||_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='blue',
                    width=2.0,
                ),
                formula=sad_filter),
            FilterDescription(
                name=('$D_{{t}} > E_{{ {size} }}\ (D_{{t}})$'.format(
                    size=100)),
                plot_options=PlotOptions(
                    style='--',
                    color='green',
                    width=1.0,
                ),
                formula=(sad_filter
                         | sigma_check(size=100))),
            FilterDescription(
                name=('$D_{{t}} > E_{{ {size} }}\ (D_{{t}})$'.format(
                    size=200)),
                plot_options=PlotOptions(style='--',
                                         color='red',
                                         width=1.5,
                                         marker='x'),
                formula=(sad_filter
                         | sigma_check(size=200) * 0.8)),
            FilterDescription(name=('VOTE'),
                              plot_options=PlotOptions(
                                  style='-',
                                  color='green',
                                  width=1.5,
                              ),
                              formula=(sad_filter
                                       | sigma_vote)),
            FilterDescription(
                # The threshold value.
                name=('$T_{{const}} = {} \in (0; 1)$'.format(self.THRESHOLD)),
                plot_options=PlotOptions(
                    style='-',
                    color='black',
                    width=2.0,
                ),
                formula=norm(l=1) | self.THRESHOLD,
            ),
        ]
예제 #9
0
    def seq_filters(self):
        """

        :return: 
        """

        # Linear delay filter. Builtin filter.
        delay = DelayFilter()

        # The incoming signal is unchanged.
        original = delay(0)

        # Shift signal to one frame. Builtin filter.
        shift = ShiftSWFilter()

        # The difference between neighboring frames.
        diff = original - shift

        # The norm of the signal. Builtin filter.
        norm = NormFilter()

        # Abstract sliding window. Builtin filter.
        sw = BaseSWFilter(min_size=2)

        sw_mean = sw | numeric.mean
        # or sw_mean = MeanSWFilter()

        sign_change = SignChangeFilter()

        atan = (diff
                | original * 256.0
                | numeric.math.atan
                | 2 * original
                | original / numeric.math.pi)

        # or atan = AtanFilter()

        def sw_mean_diff(g, l):
            """
            
            :param g: 
            :param l: 
            :return: 
            """
            return (norm(l=1)
                    | (sw_mean(s=g) - sw_mean(s=l))
                    | (sign_change * atan))

        return [
            FilterDescription(
                name='$F_{L_1} = |F_{t}|_{L_1}$',
                plot_options=PlotOptions(
                    style='-',
                    color='lightgray',
                    width=3.0,
                ),
                formula=norm(l=1),
            ),
            FilterDescription(name='$M_{50} = |\hat{\mu}_{50}(F_{L_1})|$',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='orange',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=50)),
            FilterDescription(name='$M_{100} = |\hat{\mu}_{100}(F_{L_1})|$',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='red',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=100)),
            FilterDescription(name='$M_{200} = |\hat{\mu}_{200}(F_{L_1})|$',
                              plot_options=PlotOptions(
                                  style='-',
                                  color='blue',
                                  width=2.0,
                              ),
                              formula=norm(l=1) | sw_mean(s=200)),
            FilterDescription(
                name='$|M_{200} - M_{50}| \\to_{\pm} 0$',
                plot_options=PlotOptions(
                    style='--',
                    color='blue',
                    width=1.2,
                ),
                formula=(
                    norm(l=1)
                    | (sw_mean(s=200) - sw_mean(s=50))
                    # | sign_changes
                    # | abs
                    # | original * 0.9
                )),
            FilterDescription(name='$A|M_{200} - M_{50}| \\to_{\pm} 0$',
                              plot_options=PlotOptions(
                                  style='-',
                                  marker='x',
                                  color='green',
                                  width=1.3,
                              ),
                              formula=sw_mean_diff(200, 50)),
            FilterDescription(
                # The threshold value.
                name='0',
                plot_options=PlotOptions(
                    style='-',
                    color='black',
                    width=2.0,
                ),
                formula=norm(l=1) | 0),
        ]