0

I am trying to downscale the image using "scikit-image". However I cannot show the downscaled picture through matplotlib.imshow function because of the dimension. Is there a way to prevent such dimension reduction? I put the script as well.

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 is (240, 240, 3). So what I expect for an output is (60, 60, 3). However what I get is (60, 60, 1).

1 Answers1

1

When I read the documentation of the pyramid_reduce function, I notice the parameter multichannel:

multichannel: bool,optional

Whether the last axis of the image is to be interpreted as multiple channels or another spatial dimension.

So I would suggest you to set that to True, otherwise he is treating your 2D color images as a 3D BW image:

resized = pyramid_reduce(img, downscale=4, multichannel=True)
Chris Maes
  • 35,025
  • 12
  • 111
  • 136
  • In that case, please accept this as the good answer. This way you show other users that the question is solved, and you also get 2 reputation points :) – Chris Maes Oct 19 '19 at 12:11