This commit is contained in:
2024-11-29 23:00:45 +01:00
parent 4f1158c144
commit 711b9d543f
2 changed files with 46 additions and 40 deletions

View File

@@ -52,16 +52,16 @@ def preprocess_image(image, debug_dir):
clahe = cv2.createCLAHE(clipLimit=2.0, tileGridSize=(8,8))
enhanced = clahe.apply(gray)
denoised = cv2.fastNlMeansDenoising(enhanced)
_, binary = cv2.threshold(denoised, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
# _, binary = cv2.threshold(denoised, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
# Speichern der Zwischenergebnisse im spezifischen Verzeichnis
cv2.imwrite(os.path.join(debug_dir, 'gray.png'), gray)
cv2.imwrite(os.path.join(debug_dir, 'enhanced.png'), enhanced)
cv2.imwrite(os.path.join(debug_dir, 'denoised.png'), denoised)
cv2.imwrite(os.path.join(debug_dir, 'binary.png'), binary)
# cv2.imwrite(os.path.join(debug_dir, 'binary.png'), binary)
logger.info(f"Debug images saved in: {debug_dir}")
return binary
return denoised
except Exception as e:
logger.error(f"Preprocessing error: {str(e)}")
raise