use bicubic

This commit is contained in:
千住柱間 2025-04-21 10:15:38 -04:00
commit de955a1f28
Signed by: hashirama
GPG key ID: 53E62470A86BC185

View file

@ -107,13 +107,11 @@ class TextProcessor:
return final_text
def bilinear(img):
def bicubic(img):
h, w = img.shape[:2]
# Create identity maps
map_x, map_y = np.meshgrid(np.arange(w, dtype=np.float32),
np.arange(h, dtype=np.float32))
# Remap with INTER_LINEAR
return cv2.remap(img, map_x, map_y, interpolation=cv2.INTER_LINEAR)
M = np.array([[1, 0, 0],
[0, 1, 0]], dtype=np.float32)
return cv2.warpAffine(img, M, (w, h), flags=cv2.INTER_CUBIC)
def adjust_gamma(image, gamma=1.0, alpha=1.0, beta=0):
@ -143,7 +141,7 @@ def adjust_gamma(image, gamma=1.0, alpha=1.0, beta=0):
def preprocess_image(image_path):
# Load image in grayscale (1-channel)
gray = cv2.imread(image_path, cv2.IMREAD_GRAYSCALE)
resampled = bilinear(gray)
resampled = bicubic(gray)
# Convert grayscale to 3-channel RGB by duplicating the gray channel
img = adjust_gamma(cv2.cvtColor(resampled, cv2.COLOR_GRAY2RGB),gamma=1.3,alpha=1.65,beta=-2) # perfect tunning
mat_in = ncnn.Mat.from_pixels_resize(