执行 "pyramid_reduce" 函数后尺寸减小。怎么修?
Dimension decreases after performing "pyramid_reduce" function. How to fix?
我正在尝试使用 "scikit-image" 缩小图像。但是,由于尺寸的原因,我无法通过 matplotlib.imshow 函数显示缩小后的图片。有没有办法防止这种降维?脚本我也放了
import os, cv2, glob
import numpy as np
import matplotlib.pyplot as plt
from skimage import io
from skimage.transform import pyramid_reduce,
plt.style.use('dark_background')
img_path = os.path.join(img_base_path, value[0])
img = io.imread(img_path)
resized = pyramid_reduce(img, downscale=4)
print(resized.shape)
img.shape 是 (240, 240, 3)。所以我期望的输出是 (60, 60, 3)。但是我得到的是 (60, 60, 1).
当我阅读 pyramid_reduce 函数的 documentation 时,我注意到参数 multichannel
:
multichannel: bool,optional
Whether the last axis of the image is to be
interpreted as multiple channels or another spatial dimension.
所以我建议您将其设置为 True,否则他会将您的 2D 彩色图像视为 3D BW 图像:
resized = pyramid_reduce(img, downscale=4, multichannel=True)
我正在尝试使用 "scikit-image" 缩小图像。但是,由于尺寸的原因,我无法通过 matplotlib.imshow 函数显示缩小后的图片。有没有办法防止这种降维?脚本我也放了
import os, cv2, glob
import numpy as np
import matplotlib.pyplot as plt
from skimage import io
from skimage.transform import pyramid_reduce,
plt.style.use('dark_background')
img_path = os.path.join(img_base_path, value[0])
img = io.imread(img_path)
resized = pyramid_reduce(img, downscale=4)
print(resized.shape)
img.shape 是 (240, 240, 3)。所以我期望的输出是 (60, 60, 3)。但是我得到的是 (60, 60, 1).
当我阅读 pyramid_reduce 函数的 documentation 时,我注意到参数 multichannel
:
multichannel: bool,optional
Whether the last axis of the image is to be interpreted as multiple channels or another spatial dimension.
所以我建议您将其设置为 True,否则他会将您的 2D 彩色图像视为 3D BW 图像:
resized = pyramid_reduce(img, downscale=4, multichannel=True)