我有一张我想展示的图片,pcolormesh
但我不太明白它应该如何工作。我有某种颜色的 X 和相应的 Y,但是如果我在 C 中输入一个普通数组,pcolormesh
我会得到一个错误。
我的代码:
# load image
img = cv2.imread('Distorted_resized_50.jpg')
img_array = np.asarray(img)
height, width, channels = img.shape
gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# create vector matrix
U, V = np.meshgrid(range(gray_img.shape[1]),
range(gray_img.shape[0]))
UV = np.vstack((U.flatten(),
V.flatten())).T
H, mask = cv2.findHomography(UV_cp, XYZ_gcp)
UV_warped = cv2.perspectiveTransform(np.array([UV]).astype(np.float32), H)
UV_warped = UV_warped[0]
UV_warped = UV_warped.astype(np.int)
X_warped = UV_warped[:,0].reshape((height, width))
Y_warped = UV_warped[:,1].reshape((height, width))
fig, axs = plt.subplots(figsize=(15,10))
axs.pcolormesh(X_warped, Y_warped, img_array)
有人可以帮助我吗?网站上的解释对我来说不是很清楚。一切正常,直到fig, axs = plt.subplots(figsize=(15,10))
追溯:
Traceback (most recent call last):
File "C:\Users\Yorian\Desktop\TU\Stage Shore\python_files\Rectificatie dmv foto thuis\rectify.py", line 53, in <module>
ax.pcolormesh(X_warped, Y_warped, img_array)
File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 7734, in pcolormesh
X, Y, C = self._pcolorargs('pcolormesh', *args, allmatch=allmatch)
File "C:\Python27\lib\site-packages\matplotlib\axes.py", line 7350, in _pcolorargs
numRows, numCols = C.shape
ValueError: too many values to unpack