Skip to content

Commit

Permalink
Merge pull request #30 from Juannie-PP/luyuan
Browse files Browse the repository at this point in the history
fix: 矩形外圈图片裁切bug修复
  • Loading branch information
Juannie-PP authored Feb 21, 2024
2 parents c525e20 + 6b62c27 commit 2af5a4e
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/tenon/detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def cut_image(origin_array, std, cut_value, radius=None, check_pixel=None):
pixels = tuple(
pixel
for pixel in tuple(pixel_set)
if cut_pixel < pixel < 255 - cut_value
if cut_value <= pixel <= 255 - cut_value
)
pixel_std = np.std(pixels)
if pixel_std > std:
Expand All @@ -59,14 +59,16 @@ def cut_image(origin_array, std, cut_value, radius=None, check_pixel=None):
count = 0
pixels = [[], [], []]
for b, g, r in pixel_set:
if min(b, g, r) > cut_pixel and max(b, g, r) < 255 - cut_value:
if cut_value <= min(b, g, r) <= max(b, g, r) <= 255 - cut_value:
pixels[0].append(b)
pixels[1].append(g)
pixels[2].append(r)

bgr_std = tuple(np.std(pixels[i]) for i in range(3))
bgr_std = tuple(
np.std(pixels[i]) if pixels[i] else 0 for i in range(3)
)
for pixel_std in bgr_std:
if pixel_std > std:
if pixel_std >= std:
count += 1
if count == 3:
break
Expand All @@ -83,7 +85,7 @@ def cut_image(origin_array, std, cut_value, radius=None, check_pixel=None):
pos = p + i * radius
for _ in range(p - radius):
p_x, p_y = (pos, y) if len(cut_pixel_list) % 2 else (x, pos)
pixel_point = origin_array[p_x][p_y]
pixel_point = origin_array[p_y][p_x]
pixel_set = (
{pixel_point} - {0, 255}
if isinstance(pixel_point, np.uint8)
Expand Down

0 comments on commit 2af5a4e

Please sign in to comment.