Initial commit
This commit is contained in:
28
scratch/find_logo_coords.py
Normal file
28
scratch/find_logo_coords.py
Normal file
@@ -0,0 +1,28 @@
|
||||
from PIL import Image
|
||||
|
||||
def find_logo_coords(path):
|
||||
img = Image.open(path)
|
||||
pixels = img.convert("RGBA").load()
|
||||
width, height = img.size
|
||||
|
||||
# We look for white pixels in the region x > 700 and y < 600
|
||||
white_pixels = []
|
||||
|
||||
for x in range(700, width):
|
||||
for y in range(100, 600):
|
||||
r, g, b, a = pixels[x, y]
|
||||
# White or near white text
|
||||
if a > 200 and r > 240 and g > 240 and b > 240:
|
||||
white_pixels.append((x, y))
|
||||
|
||||
if white_pixels:
|
||||
xs = [p[0] for p in white_pixels]
|
||||
ys = [p[1] for p in white_pixels]
|
||||
print(f"GOMOTO logo bounding box:")
|
||||
print(f"X: {min(xs)} to {max(xs)} (width={max(xs) - min(xs) + 1})")
|
||||
print(f"Y: {min(ys)} to {max(ys)} (height={max(ys) - min(ys) + 1})")
|
||||
else:
|
||||
print("No white pixels found in target region.")
|
||||
|
||||
if __name__ == "__main__":
|
||||
find_logo_coords("public/images/slider-courier-mask-purple.png")
|
||||
Reference in New Issue
Block a user