opencv-python icon indicating copy to clipboard operation
opencv-python copied to clipboard

Filter throws error when the number of image channel is greater than 512

Open chjz1024 opened this issue 3 years ago • 2 comments

Expected behaviour

opencv filter should return the filtered image with the same number of channel as input, i.e.

a = np.random.randint(255, size=(100,100,600)).astype(np.uint8)
cv2.blur(a, ksize=[3,3]).shape # should be (100,100,600)

Actual behaviour

error: OpenCV(4.5.3) /tmp/pip-req-build-xw6jtoah/opencv/modules/core/src/matrix.cpp:1102: error: (-215:Assertion failed) dims <= 2 && step[0] > 0 in function 'locateROI'

Steps to reproduce

  • example code
  • Ubuntu20.04
  • x86
  • opencv-python 4.5.3
Issue submission checklist
  • [ ] This is not a generic OpenCV usage question (looking for help for coding, other usage questions, homework etc.)
  • [ ] I have read the README of this repository and understand that this repository provides only an automated build toolchain for OpenCV Python packages (there is no actual OpenCV code here)
  • [ ] The issue is related to the build scripts in this repository, to the pre-built binaries or is a feature request (such as "please enable this additional dependency")
  • [x] I'm using the latest version of opencv-python

chjz1024 avatar Aug 20 '21 08:08 chjz1024

512 is current limitation for number of channels: https://github.com/opencv/opencv/blob/4.5.3/modules/core/include/opencv2/core/hal/interface.h#L69

You may want to split channels/process/merge channels of your input because channels are processed independently through filters.

alalek avatar Aug 20 '21 08:08 alalek

@alalek Many thanks for your quick response. But I'm still curious about this implementation. Is there any explicit reason for limiting the maximum number of channels or it's just a historical issue?

chjz1024 avatar Aug 20 '21 08:08 chjz1024