Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature request] Make cv2.warpAffine work with image with any number of channels #1088

Open
ternaus opened this issue Feb 22, 2025 · 2 comments

Comments

@ternaus
Copy link

ternaus commented Feb 22, 2025

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.

@samybali
Copy link

@ternaus Hi, I would like to work on this issue. Is it possible de have more details please ?

@ternaus
Copy link
Author

ternaus commented Mar 26, 2025

   ...: 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants