use bicubic
This commit is contained in:
parent
f3a78ea261
commit
de955a1f28
1 changed files with 5 additions and 7 deletions
|
|
@ -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(
|
||||
|
|
|
|||
Loading…
Reference in a new issue