From 987d0eda50ded550433ddb68e9dfd667820e7c8d Mon Sep 17 00:00:00 2001 From: berti_r Date: Fri, 18 Jul 2025 08:52:59 +0200 Subject: [PATCH] save conf --- Config/config.json | 2 +- .../metrology_functions.cpython-313.pyc | Bin 20563 -> 21233 bytes Scripts/metrology_functions.py | 35 +++- notebooks/sample.ipynb | 195 +++++++++++++++++- 4 files changed, 226 insertions(+), 6 deletions(-) diff --git a/Config/config.json b/Config/config.json index 7631451..00f98f7 100644 --- a/Config/config.json +++ b/Config/config.json @@ -3,7 +3,7 @@ "Amplitude_mm": 1, "Time_in_beam_s": 5, "Time_out_of_beam_s": 10, - "Exposure_time": 0.0004, + "Exposure_time": 0.0003, "Img_Processing": 1, "pixel_size_mu": 0.275 } \ No newline at end of file diff --git a/Scripts/__pycache__/metrology_functions.cpython-313.pyc b/Scripts/__pycache__/metrology_functions.cpython-313.pyc index 576ca0723ebf2668d2f1bbb5d68db342a9d19433..dabac194367373f0986e0c206b229b8c655101b7 100644 GIT binary patch delta 2736 zcmai0drVvB6~EuTwlRKU-k67h5Cu1a5Foq~NN9jS36NkMF|ozE*ca^9FTQ&Xg>}Pi z_ke6I&`(WB)n>3I+tN)-D(@k+o2IC0JME9H8JZGZF=^8_b!eJKmb9xjY1=v1K%%PB zuHg5b@4UWq&v(wb-dH2|t`XaPtJTE8WBmJU@WW#(wnFm$8wZ}_Jq1pVHhaoFg--5C zLR&l)o+6EEE#o|u9;ZgPdG>jVHR>p6mT1&5PbpZo!@f-0cX(W|KR!v^RjH5oI!nHQ zr|mo$u;TvyMP@y*pZ&bX!g~d_-Iwc3@EjNK_Ub&O1}LvSy~d}uw?KEc*7@Z8gry6@UGjn$l-d=fXw`e zO#g_i17w!5T{CVto2}&K&X4}M1~Lc%8aZzCy@zxSDDE0Zt)rzf-_EyXbDRizUX2Ps zFawPoHzbsE11;c#AN`)!(#RhG%YhRdXXb!EoL)y?snNsnwnvUPXpyj=6jw$bW&1v@)T9n%+NzEB!@=re0hOV>5#c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M=)uk$9oTgT% zY6W8BU1Zi$=){m`(*>2Rj)kLfS$jaly-`VA`IxGmNLIzRU=Pqt^0mc2j_WCxH3G)M zsH_WzB2rA~6J?DwAjCvjHz-O2K^*GG&rmb0oYJH?VBvrmmNOC&g#<#8esM(R1RNX` zMw|wj4Gjim4vTSE(HL$3_eSvKMgqZvD9PL?tOb&s5sHN3At9`&C7N|K7MD?g*b6Mg zZOzQ=r(PZOD;3fLB^iRP)#LYdhAHC_vAN3gb@O!#mGhn@-R7is z`RNwMjH&t~_0vO3#-fRar1znL$*WkXUi5$2c-PuI(VA?!XURYL?1E##w}|fKRwef= zoAXW^=Y;dYn)%?_&|>zLyvup1f;;8)pZdP&yxMua`{uU0=I)7?lMO%VOox4w+NAg1 zDp@v|QkSfEQ8{j*cX8@v4HhCn5yN=M`k)vOga!pFS5O)ElS}zCngpe>RAa#-opm>8 zcTre@ImY`aG~t$1+jaC1^fD0=Ak|r`v&Uq(u@tvF7m#9K!qx<$bbMW)9c?94nz%hWg0j2?-RLWmr<2MR27aEiXqQm$BL(JYh z*YB_~N5QF;O@q;R6bGV_06hkugB_*1Yt4_dXba;Bc5*AQ@|<#P6N0oI5Y4%$U$k8 z4?ue!z(I9#MxQ_v6$0@AEDHVjB5Xj(WtQIHaod3IGQdaVv*wMOD(ZJAwbES88rSNM zlVn3{hvi8f5hU-l?r=b03I0DyO0bzOvVL$hAkm=}58yf)@B;a>^~$;=-Epch*sZ{o zUTtzBdWxzm>G^?^qf*mBZ9A|49M25}@NMEVnwh|?9;fyoq@u(5ETtnG_NB4S@07eNhY zNV#u=9e!9aOt&&M7&;LvPXlU$>qyLJGqh4lKaA9tde>(|+J~lml=aX>uC>?w3r(ad Af&c&j diff --git a/Scripts/metrology_functions.py b/Scripts/metrology_functions.py index ee62b06..570d771 100644 --- a/Scripts/metrology_functions.py +++ b/Scripts/metrology_functions.py @@ -82,13 +82,42 @@ def gaussian_2d(coords, amplitude, x0, y0, sigma_x, sigma_y, offset): return amplitude * np.exp( -(((x - x0) ** 2) / (2 * sigma_x ** 2) + ((y - y0) ** 2) / (2 * sigma_y ** 2)) ) + offset +def band_pass_filter(image, low_radius, high_radius): + # Convert to float32 for FFT + img_float = np.float32(image) + + # Get shape + rows, cols = img_float.shape + crow, ccol = rows // 2 , cols // 2 # center + + # Perform FFT and shift zero frequency to center + f = np.fft.fft2(img_float) + fshift = np.fft.fftshift(f) + + # Create a band-pass mask + mask = np.zeros((rows, cols), np.uint8) + for u in range(rows): + for v in range(cols): + dist = np.sqrt((u - crow)**2 + (v - ccol)**2) + if low_radius < dist < high_radius: + mask[u, v] = 1 + + # Apply mask and inverse FFT + fshift_filtered = fshift * mask + f_ishift = np.fft.ifftshift(fshift_filtered) + img_back = np.fft.ifft2(f_ishift) + img_back = np.abs(img_back) + + return img_back def __process_img(img , retimg=0): + img_np = np.array(img) + img = band_pass_filter(img_np,15,25) img = cv2.GaussianBlur(img,(5,5),0) img = spnd.zoom(img, 4,order=3) z = np.array(img) - # Create a test image (e.g., 2D Gaussian) + """# Create a test image (e.g., 2D Gaussian) x = np.linspace(0, z.shape[0], z.shape[0]) y = np.linspace(0, z.shape[1], z.shape[1]) x, y = np.meshgrid(x, y) @@ -101,8 +130,8 @@ def __process_img(img , retimg=0): popt, _ = curve_fit(gaussian_2d, (x.ravel(), y.ravel()), z.ravel(), p0=initial_guess) x = popt[1] - y = popt[2] - x,y = np.unravel_index(np.argmax(z), z.shape) + y = popt[2]""" + y,x = np.unravel_index(np.argmax(z), z.shape) #ret1, th1 = cv2.threshold(img, 196, 255, cv2.THRESH_BINARY) #x, y = image_center_of_mass(img, plot=False, verbose=False) if retimg: diff --git a/notebooks/sample.ipynb b/notebooks/sample.ipynb index 289f814..fb8c8ce 100644 --- a/notebooks/sample.ipynb +++ b/notebooks/sample.ipynb @@ -87,6 +87,10 @@ "metadata": { "jupyter": { "source_hidden": true + }, + "ExecuteTime": { + "end_time": "2025-07-18T06:52:44.899219Z", + "start_time": "2025-07-18T06:52:44.675052Z" } }, "source": [ @@ -295,8 +299,195 @@ "\n", "\n" ], - "outputs": [], - "execution_count": null + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Path exists: C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\Scripts\n", + "Path exists: C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\Config\\config.json\n", + "Path exists: C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\Config\\config.json\n", + "Path exists: C:\\Users\\berti_r\\Python_Projects\\templates\\motion_libs\n", + "Path exists: C:\\Users\\berti_r\\Python_Projects\\StagePerformaceDocu\\Config\\measurement.json\n", + "Constructor for PLC\n", + "Connect to PLC\n", + "is_open()=True\n", + "get_local_address()=None\n", + "read_device_info()=('Plc30 App', )\n", + "GVL_APP.nAXIS_NUM=3\n", + "Constructor for axis\n" + ] + }, + { + "data": { + "text/plain": [ + "Dropdown(description='Test Type:', options=('Image Test', 'Repeatability Test', 'Static Test'), value='Image T…" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "32821ca26005425a9c8732deb7dc87ed" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Output()" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "a17b77f1308a40a08fdf90784756fe86" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "BoundedIntText(value=10, description='Nr of cycles:', max=1000, min=1)" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "ca9b34140a1b49ac976feaf9eef11b92" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Output()" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "8f31b3e0d1254f7fae2a3f0df4e5d375" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Text(value='0.0003', description='Exposure [s]:')" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "6da3d9bc3be34c88a6b19957d0d58f35" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Output()" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "4f986990fc59495dbdb5934387d40120" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "ToggleButton(value=True, description='Processing', tooltip='Toggle processing on/off')" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "d3e8ee7c113940a487f265c1c0b20b08" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Output()" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "eb679b026bb140d1bd0f3c862cfc9b00" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Button(description='Set exposure time', style=ButtonStyle())" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "cc949c4a1bad410da8289166146a509e" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Output()" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "583de4908de9490ca46e8f642ab39691" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Button(description='Start Measurement', style=ButtonStyle())" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "97bbe99cd5a843d485f61bc9ea5ecad7" + } + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/plain": [ + "Output()" + ], + "application/vnd.jupyter.widget-view+json": { + "version_major": 2, + "version_minor": 0, + "model_id": "6277546bd4a94b41a3dd142175b3b13f" + } + }, + "metadata": {}, + "output_type": "display_data" + } + ], + "execution_count": 1 }, { "cell_type": "markdown",