【发布时间】:2020-01-25 08:35:37
【问题描述】:
我想调整图像大小。我的图像包含特定值 [0, 1, 2, 7, 9]。调整大小后,会引入新的值,例如 5 之类的。我想阻止这种情况。
我目前正在使用scikit 图像调整大小功能。我已经尝试了所有插值标志,但无济于事。
编辑:显示问题的简单代码
import numpy as np
from skimage.transform import resize
vals = [0, 1, 4, 6]
N, M = 100, 100
image = np.random.choice(vals, N * M).reshape(N, M).astype('uint8')
resized_image = resize(image, (50, 50), preserve_range=True).astype('uint8')
print('vals before resizing ', np.unique(image))
print('vals after resizing ', np.unique(resized_image))
【问题讨论】:
-
我猜如果你想保留原始像素值,结果图像会有锯齿。
-
@SaeedMasoomi 是的,我不介意。
标签: python scipy resize scikit-image