import%20marimo%0A%0A__generated_with%20%3D%20%220.25.2%22%0Aapp%20%3D%20marimo.App()%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20marimo%20as%20mo%0A%0A%20%20%20%20return%20(mo%2C)%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20%23%20let's%20make%20a%20test%20for%20subpixel%20localization%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20import%20numpy%20as%20np%0A%20%20%20%20import%20matplotlib.pyplot%20as%20plt%0A%20%20%20%20from%20openpiv.pyprocess%20import%20find_first_peak%0A%0A%20%20%20%20return%20find_first_peak%2C%20np%2C%20plt%0A%0A%0A%40app.cell%0Adef%20_(np)%3A%0A%20%20%20%20N%20%3D%2064%0A%0A%20%20%20%20corr%20%3D%20np.zeros((N%2CN))%0A%0A%20%20%20%20corr%5B2%3A5%2C2%3A5%5D%20%3D%201%0A%20%20%20%20corr%5B3%2C3%5D%20%3D%202%0A%20%20%20%20corr%5B3%2C4%5D%20%3D%203%0A%20%20%20%20corr%5B3%2C5%5D%20%3D%201%0A%20%20%20%20corr%0A%20%20%20%20return%20N%2C%20corr%0A%0A%0A%40app.cell%0Adef%20_(corr%2C%20find_first_peak)%3A%0A%20%20%20%20pos%2Cheight%20%3D%20find_first_peak(corr)%0A%20%20%20%20return%20height%2C%20pos%0A%0A%0A%40app.cell%0Adef%20_(height%2C%20pos)%3A%0A%20%20%20%20pos%2Cheight%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20from%20openpiv.pyprocess%20import%20find_subpixel_peak_position%0A%0A%20%20%20%20return%20(find_subpixel_peak_position%2C)%0A%0A%0A%40app.cell%0Adef%20_(corr%2C%20find_subpixel_peak_position)%3A%0A%20%20%20%20find_subpixel_peak_position(corr)%0A%20%20%20%20return%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20let's%20find%20some%20corner%20cases%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(N%2C%20np)%3A%0A%20%20%20%20%23%20peak%20on%20the%20border%20%0A%20%20%20%20corr_1%20%3D%20np.zeros((N%2C%20N))%0A%20%20%20%20corr_1%5B%3A3%2C%20%3A3%5D%20%3D%201%0A%20%20%20%20corr_1%5B0%2C%200%5D%20%3D%202%0A%20%20%20%20corr_1%5B0%2C%202%5D%20%3D%203%0A%20%20%20%20corr_1%5B0%2C%203%5D%20%3D%201%0A%20%20%20%20corr_1%0A%20%20%20%20return%20(corr_1%2C)%0A%0A%0A%40app.cell(hide_code%3DTrue)%0Adef%20_(mo)%3A%0A%20%20%20%20mo.md(r%22%22%22%0A%20%20%20%20%23%23%20Corner%20case%201%3A%20peak%20on%20the%20border%0A%0A%20%20%20%20it%20is%20disregarded%20in%20our%20function%20because%20we%20cannot%20define%20well%20the%20subpixel%0A%20%20%20%20position.%20Or%20do%20we%3F%0A%20%20%20%20%22%22%22)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(corr_1%2C%20find_subpixel_peak_position)%3A%0A%20%20%20%20find_subpixel_peak_position(corr_1)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(corr_1%2C%20np)%3A%0A%20%20%20%20%23%20peak%20on%20the%20border%20%0A%20%20%20%20corr_2%20%3D%20np.flipud(corr_1)%0A%20%20%20%20corr_2%0A%20%20%20%20return%20(corr_2%2C)%0A%0A%0A%40app.cell%0Adef%20_(corr_2%2C%20find_subpixel_peak_position)%3A%0A%20%20%20%20find_subpixel_peak_position(corr_2)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(corr_2%2C%20np)%3A%0A%20%20%20%20corr_3%20%3D%20np.fliplr(corr_2)%0A%20%20%20%20corr_3%5B-2%2C%20-1%5D%20%3D%205%0A%20%20%20%20corr_3%0A%20%20%20%20return%20(corr_3%2C)%0A%0A%0A%40app.cell%0Adef%20_(corr_3%2C%20find_subpixel_peak_position)%3A%0A%20%20%20%20find_subpixel_peak_position(corr_3)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_()%3A%0A%20%20%20%20%23%23%20Corner%20case%202%3A%20zero%20next%20to%20the%20peak%20-%20the%20log(0)%20fails%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(N%2C%20np)%3A%0A%20%20%20%20corr_4%20%3D%20np.zeros((N%2C%20N))%0A%20%20%20%20corr_4%5B2%3A5%2C%202%3A5%5D%20%3D%201%0A%20%20%20%20corr_4%5B3%2C%203%5D%20%3D%202%0A%20%20%20%20corr_4%5B3%2C%204%5D%20%3D%203%0A%20%20%20%20%23%20corr%5B3%2C5%5D%20%3D%201%0A%20%20%20%20corr_4%0A%20%20%20%20return%20(corr_4%2C)%0A%0A%0A%40app.cell%0Adef%20_(corr_4%2C%20find_subpixel_peak_position)%3A%0A%20%20%20%20find_subpixel_peak_position(corr_4)%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(corr_4%2C%20find_subpixel_peak_position%2C%20np%2C%20plt)%3A%0A%20%20%20%20fig%2C%20ax%20%3D%20plt.subplots(figsize%3D(12%2C%2012))%0A%20%20%20%20ax.pcolor(corr_4%5B%3A8%2C%20%3A8%5D)%0A%20%20%20%20for%20eps%20in%20np.logspace(-15%2C%205)%3A%0A%20%20%20%20%20%20%20%20i%2C%20j%20%3D%20find_subpixel_peak_position(corr_4%20%2B%20eps)%0A%20%20%20%20%20%20%20%20ax.plot(i%2C%20j%2C%20'rx')%20%20%23%20print(i%2Cj)%0A%20%20%20%20return%20eps%2C%20i%2C%20j%0A%0A%0A%40app.cell%0Adef%20_(corr_4%2C%20i%2C%20j%2C%20plt)%3A%0A%20%20%20%20plt.pcolor(corr_4%5B%3A8%2C%20%3A8%5D)%0A%20%20%20%20plt.plot(i%2C%20j%2C%20'ro')%0A%20%20%20%20return%0A%0A%0A%40app.cell%0Adef%20_(corr_4%2C%20eps%2C%20find_subpixel_peak_position)%3A%0A%20%20%20%20for%20method%20in%20%5B'gaussian'%2C%20'parabolic'%2C%20'centroid'%5D%3A%0A%20%20%20%20%20%20%20%20i_1%2C%20j_1%20%3D%20find_subpixel_peak_position(corr_4%2C%20method)%0A%20%20%20%20%20%20%20%20print(i_1%2C%20j_1)%0A%20%20%20%20%20%20%20%20i_1%2C%20j_1%20%3D%20find_subpixel_peak_position(corr_4%20%2B%20eps%2C%20method)%0A%20%20%20%20%20%20%20%20print(i_1%2C%20j_1)%0A%20%20%20%20return%0A%0A%0Aif%20__name__%20%3D%3D%20%22__main__%22%3A%0A%20%20%20%20app.run()%0A
8ee073ede61e430214e7defa02359ea5