def reweight(self, x_new): """ Updat the weights. Parameters ---------- x_new: ndarray the current primal solution. Returns ------- sigma_est: ndarray the variance estimate on each scale. """ self.linear_op.op(x_new) weights = np.empty((0, ), dtype=self.weights.dtype) sigma_est = [] for scale in range(self.linear_op.transform.nb_scale): bands_array, _ = flatten(self.linear_op.transform[scale]) if scale == (self.linear_op.transform.nb_scale - 1): std_at_scale_i = 0. else: std_at_scale_i = sigma_mad(bands_array) sigma_est.append(std_at_scale_i) thr = np.ones(bands_array.shape, dtype=weights.dtype) thr *= self.thresh_factor * std_at_scale_i weights = np.concatenate((weights, thr)) self.weights = weights return sigma_est
def _op(self, data): if isinstance(data, np.ndarray): data = pysap.Image(data=data) self.transform.data = data self.transform.analysis() coeffs, coeffs_shape = flatten(self.transform.analysis_data) return coeffs, coeffs_shape
def _op(self, data): if isinstance(data, np.ndarray): data = pysap.Image(data=data) # Get the transform from queue transform = self.transform_queue.pop() transform.data = data transform.analysis() coeffs, coeffs_shape = flatten(transform.analysis_data) # Add back the transform to the queue self.transform_queue.append(transform) return coeffs, coeffs_shape
def _op(self, data): """ Define the wavelet operator for single channel. This is internal function that returns wavelet coefficients for a single channel Parameters ---------- data: ndarray or Image input 2D data array. Returns ------- coeffs: ndarray the wavelet coefficients. """ coefs_real = filter_convolve(data.real, self.transform) coefs_imag = filter_convolve(data.imag, self.transform) coeffs, coeffs_shape = flatten(coefs_real + 1j * coefs_imag) return coeffs, coeffs_shape
def op(self, data): """ Define the wavelet operator. This method returns the input data convolved with the wavelet filter. Parameters ---------- data: ndarray or Image input 2D data array. Returns ------- coeffs: ndarray the wavelet coefficients. """ if isinstance(data, numpy.ndarray): data = pysap.Image(data=data) self.transform.data = data self.transform.analysis() coeffs, self.coeffs_shape = flatten(self.transform.analysis_data) return coeffs