简体   繁体   English

光流的简单案例

[英]simple case of optical flow

General: I'm hoping that the use-case I'm about to describe is a simple case of an optical flow problem and since I don't have much knowledge on the subject, I was wondering if anyone has any suggestions on how I can approach solving my problem.一般:我希望我将要描述的用例是一个光流问题的简单案例,由于我对此主题了解不多,我想知道是否有人对我的方法有任何建议可以解决我的问题。

Research I've already done: I have began reading the High Accuracy Optical Flow Estimation Based on a Theory for Warping paper and am planning on looking over the Particle Video paper.我已经完成的研究:我已经开始阅读基于翘曲理论的高精度光流估计论文,并计划查看粒子视频论文。 I have found a MATLAB High Accuracy Optical Flow implementation of optical flow.我找到了一个 MATLAB高精度光流实现光流。 However, the papers (and the code) seem to describe concepts that are very involved and may require a lot of time for me to dig in and understand.然而,论文(和代码)似乎描述了非常复杂的概念,我可能需要很多时间来挖掘和理解。 I am hoping that the solution to my problem may be more simple.我希望我的问题的解决方案可能更简单。

Problem: I have a sequence of images.问题:我有一系列图像。 The images depict a material breakage process, where the material and background are black and the cracks are white.图像描绘了材料破损过程,其中材料和背景为黑色,裂缝为白色。 I am interested in traversing the sequence of images in reverse in an attempt to map all of the cracks that have formed in the breakage process to the first black image.我有兴趣反向遍历图像序列,试图将在破损过程中形成的所有裂缝都变成第一个黑色图像。 You can think of the material as a large puzzle and I am trying to put the pieces back together in the reverse order that they broke.你可以把这些材料想象成一个大拼图,我试图按照它们破坏的相反顺序将这些碎片重新组合在一起。

In each image, there can be some cracks that are just emerging and/or some cracks that have been fully formed (and thus created a fragment).在每个图像中,可能会有一些刚刚出现的裂缝和/或一些已经完全形成的裂缝(并因此产生了一个片段)。 Throughout the breakage process, some fragments may separate and break further.在整个破碎过程中,一些碎片可能会分离并进一步破碎。 The fragments can also move farther away from one another (the change is slight between subsequent frames).片段也可以彼此远离(后续帧之间的变化很小)。

Desired Output: All of the cracks/lines in the sequence mapped to the first image in the sequence.所需的 Output:序列中的所有裂缝/线都映射到序列中的第一个图像。

Additional Notes: Images are available in grayscale format (ie original) as well as in binary format, where the cracks have been outlined in white and the background is completely black.附加说明:图像以灰度格式(即原始)和二进制格式提供,其中裂缝已用白色勾勒出来,背景是完全黑色的。 See below for some image examples.请参阅下面的一些图像示例。

orig_img1orig_img2orig_img3

binary_img1binary_img2binary_img3

The top row shows the original images and the bottom row shows the binary images.顶行显示原始图像,底行显示二值图像。 As you can see, the crack that goes down the middle grows wider and wider as the image sequence progresses.正如你所看到的,随着图像序列的进行,中间的裂缝会变得越来越宽。 Thus, the bottom crack moves together with the lower fragment.因此,底部裂纹与下部碎片一起移动。 When traversing the sequence in reverse, I hope to algorithmically realize that the middle crack comes together as one (and map it correctly to the first image), and also map the bottom crack correctly, keeping its correct correspondence (size and position) with the bottom fragment.当反向遍历序列时,我希望在算法上实现中间裂纹作为一个(并且 map 正确地连接到第一张图像),以及 map 正确地连接到底部裂纹,保持其正确的对应关系(大小和位置)与底部片段。

A sequence typically contains about 30~40 images, so I've just shown the beginning subset.一个序列通常包含大约 30~40 张图像,所以我只展示了开始的子集。 Also, although these images don't show it, it is possible that a particular image only contains the beginning of the crack (ie its initial appearance) and in subsequent images it gets longer and longer and may join with other cracks.此外,虽然这些图像没有显示它,但特定图像可能仅包含裂缝的开始(即其初始外观),并且在随后的图像中它变得越来越长并且可能与其他裂缝连接。

Language: Although not necessary, I would like to implement the solution using MATLAB (just because most of the other code that relates to the project has been done in MATLAB).语言:虽然没有必要,但我想使用 MATLAB 来实现解决方案(因为与该项目相关的大部分其他代码已经在 MATLAB 中完成)。 However, if OpenCV may be easier, I am flexible in my language/library usage.但是,如果 OpenCV 可能更容易,我可以灵活地使用我的语言/库。

Any ideas are greatly appreciated.任何想法都非常感谢。

Traverse forward rather than reverse, and don't use optical flow.向前遍历而不是反向遍历,并且不要使用光流。 Use the fracture lines to segment the black parts, track the centroid of each black segment over time.使用断裂线分割黑色部分,随着时间的推移跟踪每个黑色部分的质心。 Whenever a new fracture line appears that cuts across a black segment, split the segment into two and continue tracking each segment separately.每当出现穿过黑色段的新断裂线时,将该段分成两部分并继续分别跟踪每个段。

From this you should be able to construct a tree structure representing the segmentation of the black parts over time.由此,您应该能够构建一个树结构,表示随着时间的推移对黑色部分的分割。 The fracture lines can be added as metadata to this tree, perhaps assigning fracture lines to the segment node in which they first appeared.断裂线可以作为元数据添加到这棵树,也许将断裂线分配给它们首次出现的段节点。

I would advise you to follow your initial idea of backtracking the cracks.我会建议你按照你最初的想法回溯裂缝。 Yo kind of know how the cracks look like so you can track all the points that belong to the crack.哟有点知道裂缝的样子,所以你可以跟踪属于裂缝的所有点。 You just track all the white points with an optical flow tracker, start with Lukas-Kanade tracker and see where you get.您只需使用光流跟踪器跟踪所有白点,从 Lukas-Kanade 跟踪器开始,看看您会得到什么。 The high-accuracy optical flow method is a global one and more general, I'll track all the pixels in the image trying to keep some smoothness everywhere.高精度光流法是一种全局性的,更通用的,我会跟踪图像中的所有像素,试图在任何地方保持一些平滑度。 The LK is a local method that will just use a small window around each point to do the tracking. LK 是一种本地方法,它只在每个点周围使用一个小的 window 来进行跟踪。 The problem is that appart from the cracks all the pixels are plain black so nothing to track there, you'll just waist time trying to track something that you can't track and you don't need to track.问题是,除了裂缝之外,所有像素都是纯黑色的,所以没有什么可以追踪的,你只会花时间试图追踪你无法追踪且不需要追踪的东西。 If lines are very straight you might end up with what's called the aperture problem and you'll get inaccurate results.如果线条非常直,您最终可能会遇到所谓的光圈问题,并且您会得到不准确的结果。 You can also try some shape fitting/deformation based on snakes.您还可以尝试一些基于蛇的形状拟合/变形。

I agree to damian.我同意达米安。 Most optical flow methods like the HAOF rely on the first-order taylor approximation of the intensity constancy constrian equation I(x,t)=I(x+v,t+dt).大多数光流方法(如 HAOF)依赖于强度常数约束方程 I(x,t)=I(x+v,t+dt) 的一阶泰勒近似。 That mean the solution depends on image derivatives where the gradient determine the motion vector magnitude and angle ie you need a certain amount of texture.这意味着解决方案取决于图像导数,其中梯度确定运动矢量幅度和角度,即您需要一定数量的纹理。 However the very low texture of your non-binarised images could be enough.但是,非二值化图像的纹理非常低就足够了。 You could try histogram equalization to increase the contrast of your input data but it is important to apply the same transformation for both input images.您可以尝试直方图均衡化来增加输入数据的对比度,但重要的是对两个输入图像应用相同的转换。 eg as follows:例如如下:

cv::Mat equalizeMat(grayInp1.rows, grayInp1.cols * 2 , CV_8UC1);
grayInp1.copyTo(equalizeMat(cv::Rect(0,0,grayInp1.cols,grayInp1.rows))); 
grayInp2.copyTo(equalizeMat(cv::Rect(grayInp1.cols,0,grayInp2.cols,grayInp2.rows)));
cv::equalizeHist(equalizeMat,equalizeMat);
equalizeMat(cv::Rect(0,0,grayInp1.cols,grayInp1.rows)).copyTo(grayInp1);
equalizeMat(cv::Rect(grayInp1.cols,0,grayInp2.cols,grayInp2.rows)).copyTo(grayInp2);
// estimate optical flow

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM