0

Image Analysis with Scipy ガイドに従っていじり回そうとしていますが、画像を変更すると多くのことがうまくいきません。例えば、

import skdemo
from skimage import data
# Rename module so we don't shadow the builtin function
import skimage.filter as filters

image = data.camera()
pixelated = image[::10, ::10]
gradient = filters.sobel(pixelated)
skdemo.imshow_all(pixelated, gradient)

これを実行すると機能しますが、使用しdata.coffee()たりdata.chelsea()、大量のエラーが発生したりします。これは、関数を使用するたびにも発生しconvolveます。理由はありますか?

RuntimeError                              Traceback (most recent call last)
<ipython-input-148-2dc2336cd0ef> in <module>()
  6 image = data.coffee()
  7 pixelated = image[::10, ::10]
----> 8 gradient = filters.sobel(pixelated)
  9 skdemo.imshow_all(pixelated, gradient)

/Users/(me)/anaconda/lib/python2.7/site-packages/skimage/filter/edges.pyc in sobel(image, mask)
 81     has to be further processed to perform edge detection.
 82     """
---> 83     return np.sqrt(hsobel(image, mask)**2 + vsobel(image, mask)**2)
 84 
 85 

/Users/(me)/anaconda/lib/python2.7/site-packages/skimage/filter/edges.pyc in hsobel(image, mask)
112     """
113     image = img_as_float(image)
--> 114     result = np.abs(convolve(image, HSOBEL_WEIGHTS))
115     return _mask_filter_result(result, mask)
116 

/Users/(me)/anaconda/lib/python2.7/site-packages/scipy/ndimage/filters.pyc in convolve(input, weights, output, mode, cval, origin)
693     """
694     return _correlate_or_convolve(input, weights, output, mode, cval,
--> 695                                   origin, True)
696 
697 

/Users/(me)/anaconda/lib/python2.7/site-packages/scipy/ndimage/filters.pyc in _correlate_or_convolve(input, weights, output, mode, cval, origin, convolution)
527     wshape = [ii for ii in weights.shape if ii > 0]
528     if len(wshape) != input.ndim:
--> 529         raise RuntimeError('filter weights array has incorrect shape.')
530     if convolution:
531         weights = weights[tuple([slice(None, None, -1)] * weights.ndim)]

RuntimeError: filter weights array has incorrect shape.
4

1 に答える 1