def get_lowpass_mask(shape, radius=0.2, softness=0): radius = round(min(shape) * radius) window = np.kaiser(radius, softness) mask = get_mask(shape, window) return mask @methods def get_var(masked_spectrum, distance, wavelength, (dx, dy)): propagation_array = get_propagation_array(masked_spectrum.shape, distance, wavelength, (dx, dy)) propagated = propagation_array * masked_spectrum reconstructed = get_shifted_idft(propagated) module = get_module(reconstructed) module_zone = get_best_contrast_zone(module) # showimage(normalize(module_zone)) fitness = module_zone.var() return fitness @methods def get_diff_var(masked_spectrum, distance, wavelength, (dx, dy)): fitness = get_var(masked_spectrum, distance, wavelength, (dx, dy)) fitness -= get_var(masked_spectrum, -distance, wavelength, (dx, dy)) return fitness @methods @cache.hybrid
def module(self): print("Module") return get_module(self.reconstructed)