Exemplo n.º 1
0
    def _stackFilters(self, flt1):
        """
        **SUMMARY**

        stack two filters of same size. channels don't matter.

        **PARAMETERS**

        * *flt1* - second filter to be stacked

        **RETURNS**

        DFT filter

        """
        if isinstance(self._numpy, type(None)):
            return flt1
        if not self.size() == flt1.size():
            warnings.warn("All the filters must be of same size")
            return None
        numpyflt = self._numpy
        numpyflt1 = flt1._numpy
        flt = np.dstack((numpyflt, numpyflt1))
        stackedfilter = DFT(size=self.size(),
                            numpyarray=flt,
                            channels=self.channels + flt1.channels,
                            type=self._type,
                            frequency=self._freqpass)
        return stackedfilter
Exemplo n.º 2
0
    def _stackFilters(self, flt1):
        """
        **SUMMARY**

        stack two filters of same size. channels don't matter.

        **PARAMETERS**

        * *flt1* - second filter to be stacked

        **RETURNS**

        DFT filter

        """
        if isinstance(self._numpy, type(None)):
            return flt1
        if not self.size() == flt1.size():
            warnings.warn("All the filters must be of same size")
            return None
        numpyflt = self._numpy
        numpyflt1 = flt1._numpy
        flt = np.dstack((numpyflt, numpyflt1))
        stackedfilter = DFT(size=self.size(), numpyarray=flt,
                            channels=self.channels+flt1.channels,
                            type=self._type, frequency=self._freqpass)
        return stackedfilter
Exemplo n.º 3
0
    def stackFilters(self, flt1, flt2):
        """
        **SUMMARY**

        Stack three signle channel filters of the same size to create
        a 3 channel filter.

        **PARAMETERS**

        * *flt1* - second filter to be stacked
        * *flt2* - thrid filter to be stacked

        **RETURNS**

        DFT filter

        **EXAMPLE**

        >>> flt1 = DFT.createGaussianFilter(dia=200, size=(380, 240))
        >>> flt2 = DFT.createGaussianFilter(dia=100, size=(380, 240))
        >>> flt2 = DFT.createGaussianFilter(dia=70, size=(380, 240))
        >>> flt = flt1.stackFilters(flt2, flt3) # 3 channel filter
        """
        if not (self.channels == 1 and flt1.channels == 1
                and flt2.channels == 1):
            warnings.warn("Filters must have only 1 channel")
            return None
        if not (self.size() == flt1.size() and self.size() == flt2.size()):
            warnings.warn("All the filters must be of same size")
            return None
        numpyflt = self._numpy
        numpyflt1 = flt1._numpy
        numpyflt2 = flt2._numpy
        flt = np.dstack((numpyflt, numpyflt1, numpyflt2))
        img = Image(flt)
        stackedfilter = DFT(size=self.size(),
                            numpyarray=flt,
                            image=img,
                            channels=3)
        return stackedfilter
Exemplo n.º 4
0
    def stackFilters(self, flt1, flt2):
        """
        **SUMMARY**

        Stack three signle channel filters of the same size to create
        a 3 channel filter.

        **PARAMETERS**

        * *flt1* - second filter to be stacked
        * *flt2* - thrid filter to be stacked

        **RETURNS**

        DFT filter

        **EXAMPLE**

        >>> flt1 = DFT.createGaussianFilter(dia=200, size=(380, 240))
        >>> flt2 = DFT.createGaussianFilter(dia=100, size=(380, 240))
        >>> flt2 = DFT.createGaussianFilter(dia=70, size=(380, 240))
        >>> flt = flt1.stackFilters(flt2, flt3) # 3 channel filter
        """
        if not(self.channels == 1 and flt1.channels == 1 and flt2.channels == 1):
            warnings.warn("Filters must have only 1 channel")
            return None
        if not (self.size() == flt1.size() and self.size() == flt2.size()):
            warnings.warn("All the filters must be of same size")
            return None
        numpyflt = self._numpy
        numpyflt1 = flt1._numpy
        numpyflt2 = flt2._numpy
        flt = np.dstack((numpyflt, numpyflt1, numpyflt2))
        img = Image(flt)
        stackedfilter = DFT(size=self.size(), numpyarray=flt, image=img, channels=3)
        return stackedfilter