(2) Create perturbed mesh grid using the method from the paperxs, ys = create_grid() # the result is like np.meshgrid请注意确保类型和大小.Notice make sure the type and the size.# xs = xs.reshape(nh, nw).astype(np.float32)# nh, nw is the height and width of the coppied image(3)使用cv2.remap重新映射:cv2.remap(...) remap(src, map1, map2, interpolation[, dst[, borderMode[, borderValue]]]) -> dst . @brief Applies a generic geometrical transformation to an image. . . The function remap transforms the source image using the specified map: . \f[\texttt{dst} (x,y) = \texttt{src} (map_x(x,y),map_y(x,y))\f]用法:dst= cv2.remap(img, xs, ys, cv2.INTER_CUBIC)这是演示结果:(4)裁剪非零区域并在必要时调整大小:(4) Crop the nonzero region and resize if necessary:相关: 从c ++转换opencv重映射代码到python 在扫描的文档中分割文本行 这篇关于如何使用变形的网格变形图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-15 21:50