有什么好方法可以将可能具有不同旋转,曝光等但具有相同背景或其他固定参考的图像对齐在一起?
Adobe Photoshop可以通过其“ Photomerge”功能实现此目的。
如何以编程方式执行此操作?是否有开放源代码应用程序?
image-processing alignment template-matching image-stitching
我正在开发一个项目,我在图像中有一个特征描述为一组X和Y坐标(每个特征5-10个点),这个特征对于这个特征是独一无二的.我还有一个包含数千个功能的数据库,每个功能都有相同类型的描述符.结果如下:
myFeature: (x1,y1), (x2,y2), (x3,y3)...
myDatabase: Feature1: (x1,y1), (x2,y2), (x3,y3)...
Feature2: (x1,y1), (x2,y2), (x3,y3)...
Feature3: (x1,y1), (x2,y2), (x3,y3)...
...
Run Code Online (Sandbox Code Playgroud)
我想在myDatabase的功能中找到myFeature的最佳匹配.
匹配这些功能的最快方法是什么?目前我正在踩着数据库中的每个功能并比较每个单独的点:
bestScore = 0
for each feature in myDatabase:
score = 0
for each point descriptor in MyFeature:
find minimum distance from the current point to the...
points describing the current feature in the database
if the distance < threshold:
there is a match to the current point in the target feature
score += 1
if score > bestScore:
save …Run Code Online (Sandbox Code Playgroud) 我打电话给:
Imgproc.matchTemplate(image, templ, result, 0);
Run Code Online (Sandbox Code Playgroud)
并且匹配的结果在Mat实例中.我找不到这个课程的任何文档.如果我理解正确,结果包含一个概率矩阵.我怎样才能找到概率的最大值?我甚至无法理解Mat实例的样子以及它包含的内容.
谢谢Eyal
我试着在窗口中实时绘制形状.形状类似于缠结,矩形,圆形,半圆形或圆形,屏幕中的"Z"使用黄色.尺寸和形状可能与原始图像不同.但程序知道所有原始形状.因为它们是预定义的.我想知道如何识别正确的形状.举个例子,

有可能这样做吗?我可以使用模板匹配吗?请在这件事上给予我帮助..
我想找到/检查主图像中的subImage /模板图像,并想知道它的坐标,
我使用了以下链接中给出的代码来实现它,
如果模板图像的大小与较大图像的匹配部分的大小完全相同,则它工作正常.
但是如果子图像按比例缩小或放大而不是匹配较大图像的一部分,则不能正确地给出结果.
opencv image-comparison machine-learning computer-vision template-matching
我有使用 python 编写的工作 OpenCV 模板匹配代码。现在我正在寻找一种方法来告诉 OpenCV 仅在提供的区域(x,y,w,h)中搜索,这可能吗?
问候, 菲利普
python opencv image-processing computer-vision template-matching
我正在尝试在 Python 中实现以下 C++ 代码:https : //opencv-code.com/tutorials/fast-template-matching-with-image-pyramid/
如果你检查C++ 代码,你会看到这个循环:
for (int i = 0; i < contours.size(); i++)
{
cv::Rect r = cv::boundingRect(contours[i]);
cv::matchTemplate(
ref(r + (tpl.size() - cv::Size(1,1))),
tpl,
res(r),
CV_TM_CCORR_NORMED
);
}
Run Code Online (Sandbox Code Playgroud)
我的Python代码:
for i in range(0, np.size(contours)-1):
x, y, w, h = cv.boundingRect(contours[i][0])
tpl_X = curr_template.shape[1]-1
tpl_Y = curr_template.shape[0]-1
result[y:h, x:w] = cv.matchTemplate(
curr_image[y:h+tpl_Y, x:w+tpl_X],
curr_template, cv.TM_CCORR_NORMED)
Run Code Online (Sandbox Code Playgroud)
当我不断收到时出现问题:ValueError:无法将输入数组从形状(53,51)广播到形状(52,52)
这个数字 (53, 51) (52,52) 可能会改变,因为我只是稍微修改了结果或 curr_image 中的坐标,但这不是正确的答案。
这是我当前的代码:
import cv2 as cv …Run Code Online (Sandbox Code Playgroud) 我正在寻找一种算法来计算以下内容:我有一个带有预定义区域的图像(附加图像上的绿色图像).用户绘制红色矩形,算法应计算红色矩形是否与绿色矩形匹配.例如,附加图片上的红色矩形的位置就可以了.
计算这个的好方法是什么?有没有最佳实践算法?
我的想法是计算红色矩形的中间,然后确定中间是否在绿色矩形内.另外,我会计算长度和高度是否与绿色长度和高度相匹配(25%或更多).
这是一个好主意吗?还有其他建议吗?
algorithm image-processing pattern-matching template-matching
我在 opencv 和模板匹配方面遇到了一些麻烦,所以我希望这里有人可以帮助迷失的灵魂。
因此,作为我正在使用的代码的一部分,我有以下两行我不太理解。
result = cv2.matchTemplate(edged, template, cv2.TM_CCOEFF)
(_, maxVal, _, maxLoc) = cv2.minMaxLoc(result)
Run Code Online (Sandbox Code Playgroud)
根据我的理解,第一行在变量“result”中存储了一个相关系数。这反过来又被传递到cv2.minMaxLoc(...)它依次生成一个由 (minVal, maxVal, minLoc, maxLoc) 组成的 4 元素数组,其中我们只对 maxVal 和 maxLoc 感兴趣。
在打印 maxVal 的值时,我似乎得到了 2,000,000 到 7,000,000 之间的值,具体取决于模板、光照条件等。
我的问题如下:
maxVal 是什么意思?
maxVal 的范围是多少?
哪些物理特性会影响 maxVal 的值?
在此先感谢您的帮助和指导!
我在实时相机捕获中使用 opencv 模板匹配,并收到错误消息:
error: (-215) _img.size().height <= _templ.size().height && _img.size().width <= _templ.size().width in function matchTemplate
Run Code Online (Sandbox Code Playgroud)
环境:
OpenCV: 3.4.1
Python3
Run Code Online (Sandbox Code Playgroud)
代码(是官网doc的例子,我只是替换了图片)
import cv2 as cv
import numpy as np
img_rgb = cv.imread('mybook.png')
img_gray = cv.cvtColor(img_rgb, cv.COLOR_BGR2GRAY)
template = cv.imread('book.jpg',0)
w, h = template.shape[::-1]
res = cv.matchTemplate(img_gray,template,cv.TM_CCOEFF_NORMED)
threshold = 0.8
loc = np.where( res >= threshold)
for pt in zip(*loc[::-1]):
cv.rectangle(img_rgb, pt, (pt[0] + w, pt[1] + h), (0,0,255), 2)
cv.imwrite('res.png',img_rgb)
Run Code Online (Sandbox Code Playgroud)
我想知道我是否做错了什么?非常感谢!