opencv-python
opencv-python copied to clipboard
[Feature request] Make cv2.warpAffine work with image with any number of channels
Describe the feature and motivation
Currently cv2.warpAffine supports only 1, 3 and 4 channels images, while for problems of medical or satellite imagery we may have any. Would be great to add support for any number of channels.
@ternaus Hi, I would like to work on this issue. Is it possible de have more details please ?
...: import cv2
...: import numpy as np
...: from matplotlib import pyplot as plt
...:
...:
...:
...: rows, cols, ch = 256, 256, 11
...:
...: img = np.random.randint(0, 255, size=(rows, cols, ch))
...:
...: pts1 = np.float32([[50, 50],
...: [200, 50],
...: [50, 200]])
...:
...: pts2 = np.float32([[10, 100],
...: [200, 50],
...: [100, 250]])
...:
...: M = cv2.getAffineTransform(pts1, pts2)
...: dst = cv2.warpAffine(img, M, (cols, rows))
---------------------------------------------------------------------------
error Traceback (most recent call last)
Cell In[2], line 20
15 pts2 = np.float32([[10, 100],
16 [200, 50],
17 [100, 250]])
19 M = cv2.getAffineTransform(pts1, pts2)
---> 20 dst = cv2.warpAffine(img, M, (cols, rows))
error: OpenCV(4.11.0) /Users/xperience/GHA-Actions-OpenCV/_work/opencv-python/opencv-python/opencv/modules/imgproc/src/imgwarp.cpp:1897: error: (-215:Assertion failed) ifunc != 0 in function 'remap'
@samybali and if you ch as 1, 3, or 4 it works