mirror of
https://gitee.com/sui-feng-cb/AzurLaneAutoScript1
synced 2026-03-12 05:08:19 +08:00
Opt: Delete low confidence result in OCR
This commit is contained in:
@@ -330,6 +330,24 @@ def extract_letters(image, letter=(255, 255, 255), threshold=128):
|
||||
return cv2.multiply(cv2.add(positive, negative), 255.0 / threshold)
|
||||
|
||||
|
||||
def extract_white_letters(image, threshold=128):
|
||||
"""Set letter color to black, set background color to white.
|
||||
This function will discourage color pixels (Non-gray pixels)
|
||||
|
||||
Args:
|
||||
image: Shape (height, width, channel)
|
||||
threshold (int):
|
||||
|
||||
Returns:
|
||||
np.ndarray: Shape (height, width)
|
||||
"""
|
||||
image = np.array(image)
|
||||
r, g, b = cv2.split(cv2.subtract((255, 255, 255, 0), image))
|
||||
minimum = cv2.min(cv2.min(r, g), b)
|
||||
maximum = cv2.max(cv2.max(r, g), b)
|
||||
return cv2.multiply(cv2.add(maximum, cv2.subtract(maximum, minimum)), 255.0 / threshold)
|
||||
|
||||
|
||||
def red_overlay_transparency(color1, color2, red=247):
|
||||
"""Calculate the transparency of red overlay.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user