def _stack_filters(self, flt1): """ Stack two filters of same size. :param flt1: second filter to be stacked. :return: DFT filter """ if isinstance(self._narray, type(None)): return flt1 if not self.size() == flt1.size(): warnings.warn("All the filters must be of same size.") return None numpy_array = self._narray numpy_array1 = flt1.narray flt = np.dstack((numpy_array, numpy_array1)) stacked_filter = DFT(size=self.size(), array=numpy_array, channels=self.channels+flt1.channels, type=self._type, frequence=self._freq_pass) return stacked_filter
def stack_filters(self, flt1, flt2): """ Stack three single channel filters of the same size to create a 3 channel filter. :param flt1: second filter to be stacked :param flt2: third filter to be stacked :return: DFT 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 the same size.") return None numpy_filter = self._narray numpy_filter1 = flt1.narray numpy_filter2 = flt2.narray flt = np.dstack((numpy_filter, numpy_filter1, numpy_filter2)) image = PhloxAR.core.image.Image(flt) stacked_filter = DFT(size=self.size(), array=flt, image=image, channels=3) return stacked_filter