def get_secure_phase(spectrum, until=1.): """ If we knew what it was we were doing it would not be called research.""" rows, cols = spectrum.shape def get_partial_phase(max_value): mask = spectrum >= max_value masked = spectrum * mask phase = get_phase(get_shifted_idft(masked)) paraboloid = get_fitted_paraboloid(phase) phase -= paraboloid return paraboloid, phase % tau # Initial phase sec_phase = np.zeros_like(spectrum, float) values = sorted(spectrum.ravel(), reverse=True) bisector = Bisector(values) while bisector.value() > values.min(): paraboloid, phase = get_partial_phase(bisector.value()) is_wrapped, phase = align_phase((phase - sec_phase) % tau, 20) print(is_wrapped) if is_wrapped: bisector.to_left() else: print("add ring") sec_phase += phase sec_phase += paraboloid showimage(sec_phase) bisector.reset_to_right() return sec_phase
def main(): from pea import PEA from autopipe import showimage pea = PEA() pea.filename_holo = "../../../../documentos/carlos/enfused-sub/0427-0433-04X-568-c.tiff" wg = wrapped_gradient(pea.phase) showimage(wg) return 0
def main(): from scipy.misc import lena from autopipe import showimage x, y = np.mgrid[:512, :512] eye = lena() data = get_paraboloid(x, y, 1, 250, 3, 300, 5) data /= data.ptp() / 256. * 0.25 noisy = (data + eye).astype(float) noisy /= noisy.ptp() / 20 print noisy.ptp() noisy %= tau fitted = get_fitted_paraboloid(noisy) showimage(eye, noisy, fitted % tau, (noisy - fitted) % tau) return 0
def main(): import pea import image from autopipe import showimage import unwrap p = pea.PEA() p.unwrapper = unwrap.unwrap_qg p.filename_holo = "feh_004123_000001_tmpXAePgu.png" phase = image.correct_cmos_stripes(p.unwrapped_phase) module = p.module comb = array((phase.ravel(), module.ravel())).transpose() pca = PCA_nipals2(comb) p = pca[0] showimage(p[:, 0].reshape(phase.shape)) return 0
def main(): import autopipe canvas = Canvas((512, 512)) color = (.3, .3, .3, 1) curve = Curve(((75, 75, 100), (75, 325, 100), (325, 325, 100), (300, 75, 1/3.)), color) canvas.draw(curve, verbose=2) curve = Curve(((90, 90, 20), (90, 300, 100), (300, 200, 150)), color) canvas.draw(curve) curve = Curve(((120, 120, 110), (230, 260, 130)), color) canvas.draw(curve) array = canvas.as_array() autopipe.showimage(array)
def main(): import autopipe canvas = Canvas((512, 512)) color = (.3, .3, .3, 1) curve = Curve( ((75, 75, 100), (75, 325, 100), (325, 325, 100), (300, 75, 1 / 3.)), color) canvas.draw(curve, verbose=2) curve = Curve(((90, 90, 20), (90, 300, 100), (300, 200, 150)), color) canvas.draw(curve) curve = Curve(((120, 120, 110), (230, 260, 130)), color) canvas.draw(curve) array = canvas.as_array() autopipe.showimage(array)
# phase = phase / phase.ptp() # phase -= phase.min() def processor(t_sigma, t_level, sigma, low_threshold, high_threshold): t_sigma = sigmoid(t_sigma) * 20 t_level = sigmoid(t_level) sigma = sigmoid(sigma) * 50 phase = p.unwrapped_phase local_context = gaussian_filter(phase, t_sigma) phase = (phase - local_context) / (1 - t_level) phase /= phase.ptp() phase -= phase.min() cannied = canny(phase, sigma, low_threshold, high_threshold) return np.vstack((phase, cannied)) initial_values = None # Unwrapped # initial_values = [(-1.469, -3.429, -4.503, 1.695), (-1.519, -4.142, -4.525, 2.041), (-1.699, -3.178, -4.871, 1.224), (-1.416, -3.636, -5.074, 1.400), (-1.078, -4.102, -4.455, 1.525)] # sinoided # initial_values = [(2.671, -1.034, -1.752, -11.838), (2.863, -0.547, -1.404, -11.574), (3.073, -0.643, -1.065, -10.938), (3.014, -1.110, -1.634, -11.724), (2.188, -1.027, -1.925, -11.677)] # denoised unwrapped # [Point(5.095, 4.652, -2.600, -11.167, 0.369), Point(5.050, 4.233, -1.862, -10.801, 0.226), Point(4.725, 4.596, -2.015, -11.064, 0.065), Point(3.842, 4.795, -1.818, -10.624, -0.691), Point(4.410, 4.721, -1.873, -11.075, 0.000), Point(4.824, 4.758, -1.950, -11.196, -0.007)] # denoised tonemaped unwrapped phase # [Point(11.302, 32.193, -17.454, 0.062, -23.372), Point(11.606, 33.481, -17.760, 0.066, -24.366), Point(10.540, 31.750, -17.362, 0.080, -23.049), Point(9.432, 33.442, -19.050, 0.111, -23.610), Point(11.899, 32.981, -18.453, 0.123, -23.621), Point(11.175, 32.647, -18.048, 0.390, -23.549)] plt_args = {"cmap": plt.get_cmap("bone")} amoeba = Amoeba(processor, initial_values, plt_args=plt_args) amoeba.iterate(distance=1) print(amoeba.points) showimage(amoeba.points[0].value)
# phase = phase / phase.ptp() # phase -= phase.min() def processor(t_sigma, t_level, sigma, low_threshold, high_threshold): t_sigma = sigmoid(t_sigma) * 20 t_level = sigmoid(t_level) sigma = sigmoid(sigma) * 50 phase = p.unwrapped_phase local_context = gaussian_filter(phase, t_sigma) phase = (phase - local_context) / (1 - t_level) phase /= phase.ptp() phase -= phase.min() cannied = canny(phase, sigma, low_threshold, high_threshold) return np.vstack((phase, cannied)) initial_values = None # Unwrapped # initial_values = [(-1.469, -3.429, -4.503, 1.695), (-1.519, -4.142, -4.525, 2.041), (-1.699, -3.178, -4.871, 1.224), (-1.416, -3.636, -5.074, 1.400), (-1.078, -4.102, -4.455, 1.525)] # sinoided # initial_values = [(2.671, -1.034, -1.752, -11.838), (2.863, -0.547, -1.404, -11.574), (3.073, -0.643, -1.065, -10.938), (3.014, -1.110, -1.634, -11.724), (2.188, -1.027, -1.925, -11.677)] # denoised unwrapped # [Point(5.095, 4.652, -2.600, -11.167, 0.369), Point(5.050, 4.233, -1.862, -10.801, 0.226), Point(4.725, 4.596, -2.015, -11.064, 0.065), Point(3.842, 4.795, -1.818, -10.624, -0.691), Point(4.410, 4.721, -1.873, -11.075, 0.000), Point(4.824, 4.758, -1.950, -11.196, -0.007)] # denoised tonemaped unwrapped phase # [Point(11.302, 32.193, -17.454, 0.062, -23.372), Point(11.606, 33.481, -17.760, 0.066, -24.366), Point(10.540, 31.750, -17.362, 0.080, -23.049), Point(9.432, 33.442, -19.050, 0.111, -23.610), Point(11.899, 32.981, -18.453, 0.123, -23.621), Point(11.175, 32.647, -18.048, 0.390, -23.549)] plt_args = {"cmap":plt.get_cmap("bone")} amoeba = Amoeba(processor, initial_values, plt_args=plt_args) amoeba.iterate(distance=1) print(amoeba.points) showimage(amoeba.points[0].value)