Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Thin plate spline transform gives solid color for certain inputs

未关闭
#1,139 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
opencv, python

调研方向

首先,使用 test.png 以及报告的 Python 3.13.5 和 OpenCV 4.12.0.88 版本运行提供的 Python 复现程序。比较九点变换和八点变换,然后确定故障所在,并验证九点恒等变换不再生成纯色图像。

由索引模型根据 Issue 内容生成。

描述

question

Certain combinations of points for a thin plate spline transformation cause the transformed image to be one solid color. Removing the offending combination of points will cause the image to transform as expected.

Below is code that reads the attached image and applys a transformation which should do nothing to the image. The first transformation erroneously turns the whole image a single color. The second transformation uses one less point and correctly does nothing to the image. Im not sure what makes combinations of points not compatible with each other. The points in the code are outside of the uploaded image, since the points were originally being used on a much larger image. I can't upload that here due to file size restrictions. However behavior on the smaller image is the same. Versions are Python 3.13.5, opencv-contrib-python 4.12.0.88, opencv-python 4.12.0.88, Windows 10.

import cv2
import numpy

# Variable initilization
img = cv2.imread('test.png')
base_points = numpy.array([[ 121, 5213],
                    [6197, 5197],
                    [1627, 3481],
                    [3146, 3477],
                    [4668, 3473],
                    [1616, 1752],
                    [4655, 1744],
                    [6179, 1742],
                    [  87,   29]])

# In this example a tps transformation is done.
# The input and output points are the same so the image shouldn't change.
# The whole image will be the color of the one of the corner pixels.
points = base_points[:]
points = points.reshape((-1,points.shape[0],2)).astype(numpy.int32)
tps = cv2.createThinPlateSplineShapeTransformer()
matches = [cv2.DMatch(i, i, 0) for i in range(points.shape[1])]
tps.estimateTransformation(points, points, matches)
warped1 = tps.warpImage(img)
cv2.imshow('Whole image is one color', warped1)

# This example uses one less point.
# The output is the input image, which is what would be expected.
points = base_points[1:]
points = points.reshape((-1,points.shape[0],2)).astype(numpy.int32)
tps = cv2.createThinPlateSplineShapeTransformer()
matches = [cv2.DMatch(i, i, 0) for i in range(points.shape[1])]
tps.estimateTransformation(points, points, matches)
warped2 = tps.warpImage(img)
cv2.imshow('Image is as expected', warped2)

cv2.waitKey(0)

Correct image: Image

Single color image: Image

主要语言
Python
星标
5.4k
派生
1k
平均合并
22 小时 17 分钟
30 天内合并 PR
3

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

opencv/opencv-python 的其他 Issue

查看 opencv/opencv-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。