save conf

This commit is contained in:
2025-07-18 09:20:34 +02:00
parent 987d0eda50
commit aecc9fe30e
7 changed files with 206 additions and 24 deletions

View File

@@ -1,9 +1,9 @@
{
"Number_of_cycles": 10,
"Number_of_cycles": 50,
"Amplitude_mm": 1,
"Time_in_beam_s": 5,
"Time_out_of_beam_s": 10,
"Exposure_time": 0.0003,
"Exposure_time": 0.0004,
"Img_Processing": 1,
"pixel_size_mu": 0.275
}

View File

@@ -82,9 +82,37 @@ 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):
def compute_gradient(img, pos, h=1e-2):
x, y = pos
x_int, y_int = int(x), int(y)
# Ensure position is within bounds
if x_int <= 0 or x_int >= img.shape[1] - 1 or y_int <= 0 or y_int >= img.shape[0] - 1:
return np.array([0.0, 0.0])
# Use central difference
dx = (img[y_int, x_int + 1] - img[y_int, x_int - 1]) / 2
dy = (img[y_int + 1, x_int] - img[y_int - 1, x_int]) / 2
return np.array([dx, dy])
def gradient_ascent(img, start_pos, lr=0.8, max_iter=1000, tol=1e-4):
pos = np.array(start_pos, dtype=float)
path = [tuple(pos)]
for i in range(max_iter):
grad = compute_gradient(img, pos)
if np.linalg.norm(grad) < tol:
break
pos += lr * grad
# Clip to image boundaries
pos = np.clip(pos, [0, 0], [img.shape[1] - 1, img.shape[0] - 1])
path.append(tuple(pos))
return pos, path
def band_pass_filter(img_float, low_radius, high_radius):
# Convert to float32 for FFT
img_float = np.float32(image)
# Get shape
rows, cols = img_float.shape
@@ -112,12 +140,12 @@ def band_pass_filter(image, low_radius, high_radius):
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)
#z = band_pass_filter(z,5,10)
# 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)
@@ -126,12 +154,14 @@ def __process_img(img , retimg=0):
# Flatten and fit
x_gues, y_gues = image_center_of_mass(img, plot=False, verbose=False)
initial_guess = (180, x_gues, y_gues, 4, 4, 1)
"""
initial_guess = (180, x_gues, y_gues, 10, 10, 1)
popt, _ = curve_fit(gaussian_2d, (x.ravel(), y.ravel()), z.ravel(), p0=initial_guess)
x = popt[1]
y = popt[2]"""
y,x = np.unravel_index(np.argmax(z), z.shape)
result , path = gradient_ascent(img, (x_gues, y_gues))
#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:

View File

@@ -0,0 +1 @@
{"Number_of_cycles": 50, "Amplitude_mm": 1, "Time_in_beam_s": 5, "Time_out_of_beam_s": 10, "Exposure_time": 0.0004, "Img_Processing": 1, "pixel_size_mu": 0.275}

View File

@@ -0,0 +1,50 @@
1 0.000000 0.000000 99.911 159.177 1752822522.804
2 0.000000 0.000000 100.435 158.670 1752822522.963
3 0.000000 0.000000 100.657 158.194 1752822523.118
4 0.000000 0.000000 100.489 157.957 1752822523.276
5 0.000000 0.000000 101.236 158.167 1752822523.431
6 0.000000 0.000000 101.998 158.805 1752822523.588
7 0.000000 0.000000 101.104 157.610 1752822523.744
8 0.000000 0.000000 102.831 157.871 1752822523.901
9 0.000000 0.000000 101.276 158.870 1752822524.060
10 0.000000 0.000000 101.516 157.857 1752822524.216
11 0.000000 0.000000 102.231 157.941 1752822524.373
12 0.000000 0.000000 101.439 157.859 1752822524.529
13 0.000000 0.000000 100.229 157.825 1752822524.687
14 0.000000 0.000000 102.200 157.517 1752822524.843
15 0.000000 0.000000 101.618 158.607 1752822525.001
16 0.000000 0.000000 102.166 158.605 1752822525.159
17 0.000000 0.000000 100.466 157.836 1752822525.315
18 0.000000 0.000000 102.770 157.952 1752822525.472
19 0.000000 0.000000 98.936 158.053 1752822525.628
20 0.000000 0.000000 100.290 158.706 1752822525.786
21 0.000000 0.000000 100.885 158.059 1752822525.946
22 0.000000 0.000000 100.919 158.444 1752822526.103
23 0.000000 0.000000 102.151 157.762 1752822526.259
24 0.000000 0.000000 101.008 158.049 1752822526.417
25 0.000000 0.000000 101.967 158.513 1752822526.574
26 0.000000 0.000000 100.785 157.719 1752822526.730
27 0.000000 0.000000 101.658 158.574 1752822526.887
28 0.000000 0.000000 100.977 157.223 1752822527.044
29 0.000000 0.000000 101.239 157.911 1752822527.200
30 0.000000 0.000000 100.501 157.986 1752822527.357
31 0.000000 0.000000 101.480 157.815 1752822527.514
32 0.000000 0.000000 101.281 158.501 1752822527.671
33 0.000000 0.000000 99.914 158.413 1752822527.829
34 0.000000 0.000000 101.093 158.904 1752822527.985
35 0.000000 0.000000 101.614 158.302 1752822528.142
36 0.000000 0.000000 101.670 158.248 1752822528.298
37 0.000000 0.000000 102.294 158.425 1752822528.455
38 0.000000 0.000000 100.704 157.848 1752822528.613
39 0.000000 0.000000 102.042 157.958 1752822528.769
40 0.000000 0.000000 100.797 157.837 1752822528.926
41 0.000000 0.000000 100.027 158.339 1752822529.084
42 0.000000 0.000000 100.178 157.748 1752822529.241
43 0.000000 0.000000 102.065 158.095 1752822529.397
44 0.000000 0.000000 99.348 158.559 1752822529.554
45 0.000000 0.000000 101.598 158.713 1752822529.711
46 0.000000 0.000000 101.215 157.951 1752822529.867
47 0.000000 0.000000 101.002 157.982 1752822530.023
48 0.000000 0.000000 99.415 158.754 1752822530.181
49 0.000000 0.000000 101.446 158.017 1752822530.337
50 0.000000 0.000000 102.079 158.161 1752822530.493

File diff suppressed because one or more lines are too long

View File

@@ -89,8 +89,8 @@
"source_hidden": true
},
"ExecuteTime": {
"end_time": "2025-07-18T06:52:44.899219Z",
"start_time": "2025-07-18T06:52:44.675052Z"
"end_time": "2025-07-18T07:08:19.394842Z",
"start_time": "2025-07-18T07:08:19.144708Z"
}
},
"source": [
@@ -313,7 +313,7 @@
"Connect to PLC\n",
"is_open()=True\n",
"get_local_address()=None\n",
"read_device_info()=('Plc30 App', <pyads.structs.AdsVersion object at 0x00000214B0829550>)\n",
"read_device_info()=('Plc30 App', <pyads.structs.AdsVersion object at 0x000001EEF4ADD6A0>)\n",
"GVL_APP.nAXIS_NUM=3\n",
"Constructor for axis\n"
]
@@ -326,7 +326,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "32821ca26005425a9c8732deb7dc87ed"
"model_id": "6828982f64e5493793d19e4eefbbbae1"
}
},
"metadata": {},
@@ -340,7 +340,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "a17b77f1308a40a08fdf90784756fe86"
"model_id": "396ab16c07ce435ab7d0c2da4e9d7f92"
}
},
"metadata": {},
@@ -354,7 +354,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "ca9b34140a1b49ac976feaf9eef11b92"
"model_id": "36a81552307445258c2468c5fb0bd6d1"
}
},
"metadata": {},
@@ -368,7 +368,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "8f31b3e0d1254f7fae2a3f0df4e5d375"
"model_id": "6df23067d8534062841a367c50a1dba3"
}
},
"metadata": {},
@@ -377,12 +377,12 @@
{
"data": {
"text/plain": [
"Text(value='0.0003', description='Exposure [s]:')"
"Text(value='0.0004', description='Exposure [s]:')"
],
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "6da3d9bc3be34c88a6b19957d0d58f35"
"model_id": "c45b50ce47d443ba87483511c8c1d8c7"
}
},
"metadata": {},
@@ -396,7 +396,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "4f986990fc59495dbdb5934387d40120"
"model_id": "72c6cd1366a14323a2c23111d76895e1"
}
},
"metadata": {},
@@ -410,7 +410,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "d3e8ee7c113940a487f265c1c0b20b08"
"model_id": "bb2bb30d673b443398a79cb749f93dd7"
}
},
"metadata": {},
@@ -424,7 +424,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "eb679b026bb140d1bd0f3c862cfc9b00"
"model_id": "e27b10214ab34805abd55d7f597e0303"
}
},
"metadata": {},
@@ -438,7 +438,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "cc949c4a1bad410da8289166146a509e"
"model_id": "c521adfeb1134ede8a43ff85992c80d0"
}
},
"metadata": {},
@@ -452,7 +452,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "583de4908de9490ca46e8f642ab39691"
"model_id": "76f186ccdfd44632955d378d0cb8d21c"
}
},
"metadata": {},
@@ -466,7 +466,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "97bbe99cd5a843d485f61bc9ea5ecad7"
"model_id": "f6e7b5a8a82c4219984394c8b34d1a52"
}
},
"metadata": {},
@@ -480,7 +480,7 @@
"application/vnd.jupyter.widget-view+json": {
"version_major": 2,
"version_minor": 0,
"model_id": "6277546bd4a94b41a3dd142175b3b13f"
"model_id": "4e8cb912dda4474c9e30d8eaa4a23df4"
}
},
"metadata": {},