49 lines
2.0 KiB
Python
49 lines
2.0 KiB
Python
import cv2
|
|
import numpy as np
|
|
import os
|
|
|
|
def process_stream_image():
|
|
# 1. Load the stream image
|
|
img = cv2.imread("assets/environment/stream_reference.png", cv2.IMREAD_UNCHANGED)
|
|
|
|
# If no alpha channel, add one
|
|
if img.shape[2] == 3:
|
|
img = cv2.cvtColor(img, cv2.COLOR_BGR2BGRA)
|
|
|
|
# Remove white/black background if present (assuming white based on typical reference images, or do refined masking)
|
|
# The user image "uploaded_media_0" looks like an isometric block. It might have a white background.
|
|
# Simple thresholding for white background removal:
|
|
gray = cv2.cvtColor(img, cv2.COLOR_BGRA2GRAY)
|
|
|
|
# Create mask for whiteish pixels
|
|
_, mask = cv2.threshold(gray, 240, 255, cv2.THRESH_BINARY)
|
|
|
|
# Invert mask (keep non-white)
|
|
mask_inv = cv2.bitwise_not(mask)
|
|
|
|
# Apply to alpha channel
|
|
# Note: This is a rough removal. Ideally we'd use the provided transparent asset if user gave PNG with alpha.
|
|
# But often users upload screenshots.
|
|
# Let's check if the corners are white.
|
|
|
|
# Actually, let's just use the image as is if it has alpha, else remove white.
|
|
# But to be safe for "systematic" placement, let's resize it to a standard tile size or keep it prop-sized.
|
|
# It looks like a big chunk. Let's keep resolution but ensure background is clean.
|
|
|
|
img[:, :, 3] = cv2.bitwise_and(img[:, :, 3], mask_inv)
|
|
|
|
# Save as the actual game asset
|
|
cv2.imwrite("assets/environment/potok_segment.png", img)
|
|
print("Stream segment processed and saved.")
|
|
|
|
def identify_and_remove_ugly_grass():
|
|
# The user wants "the other grass image" removed.
|
|
# Reference saved at assets/vegetation/ugly_grass_ref.png
|
|
# We don't need to process it, just know that we need to stop using the asset that looks like this.
|
|
# The user said "jo odstrani iz igre".
|
|
# I suspect it matches 'trava_rob.png' or similar.
|
|
# In the code, I will switch usage of 'trava_rob' to one of the better grasses.
|
|
pass
|
|
|
|
process_stream_image()
|