通过图像减法分割的优化算法 [英] Optimizing algorithm for segmentation through image substraction

查看:540
本文介绍了通过图像减法分割的优化算法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于OpenCV中的项目,我希望细分移动对象尽可能好,当然噪音最小。



想要使用图片减法算法。
我已经有一个正在运行的程序,但是没有找到一个方法来获得公平的结果。



我已经有以下(灰度)图像:

  IplImage * grayScale; 
IplImage * lastFrame;
IplImage * secondLastFrame;
IplImage * thirdLastFrame;

到目前为止,我已经尝试了减少当前帧图像和最后一个框架 cvSub(); cvAbsDiff(); 获取移动部件。



但是,不幸的是,我仍然得到很多噪音(即,由于在有风的时候移动的树木),如果移动的对象相当大,并且具有同质性的颜色(我们说一个人在白色或黑色衬衫)减法只检测图像在人左侧和右侧的变化,而不是体上本身,所以一个对象有时被检测为两个对象...

  cvAbsDiff(this-> lastFrame,grayScale,output); 
cvThreshold(output,output,10,250,CV_THRESH_BINARY);
cvErode(output,output,NULL,2);
cvDilate(output,output,NULL,2);

为了摆脱这种噪音,我试着用 cvErode () cvDilate()但是这是相当慢的,如果在屏幕上的移动对象小,侵蚀删除相当多的



之后,我做一个 cvFindContours()

code>获得轮廓,检查大小,如果它适合在移动对象周围绘制一个矩形。但结果很差,因为通常一个对象被分割成几个矩形,由于分割不良。



朋友现在告诉我,我可能会尝试使用两个以下的框架减法,因为这可能已经减少了噪音...但我真的不知道他的意思,如何我应该添加/减去帧,以获得一个几乎无噪音,显示足够大的对象blob的图像。 p>

有人可以帮我吗?如何使用多个帧来获得尽可能最小的噪声,但是移动物体有足够大的斑点的图像?



添加:

已在上传了当前视频: http://temp.tinytall.de/ 也许有人想试试it there ...



这是一个框架:左图显示我的cvFindContours()结果,右图是分段图像,然后我尝试找到轮廓...





所以一个大的对象,它工作正常,如果他们移动足够快...即自行车..但在步行的人并不总是得到一个好的结果,

解决方案

给定三个相邻的帧A,B,C,你可以得到两个帧差异X和Y.通过组合X和Y(通过,例如阈值处理,然后逻辑 AND 操作),可以减少噪声的影响。不必要的副作用是运动检测区域将略小于理想值( AND 操作将减少面积)。



由于图像序列运动估计已经进行了好几十年的研究,因此您可能需要阅读更复杂的运动检测方法,例如工作与运动矢量字段。 Google Scholar是您的朋友。


for a project in OpenCV I would like to segment moving objects as good as possible with of course minimal noise.

For this I would like to use an image substraction algorithm. I already have a running program but didn't find a way today to get fair enough results.

I already have the following (grayscale) images given:

IplImage* grayScale;
IplImage* lastFrame;
IplImage* secondLastFrame;
IplImage* thirdLastFrame;

So far I have tried to substract current frames image and the last frame with cvSub(); or with cvAbsDiff(); to get the moving parts.

But unfortunately I still get a lot of noise there (i.e. due to slightly moving trees when it's windy) and if the object that moves is quite big and has a homogenic color (let's say a person in a white or black shirt), the substraction only detects the changes in the image on the left and right side of the person, not on the body itself, so one object is sometimes detected as two objects...

cvAbsDiff(this->lastFrame,grayScale,output);
cvThreshold(output,output,10,250, CV_THRESH_BINARY);
cvErode(output,output, NULL, 2);
cvDilate(output,output, NULL, 2);

To get rid of this noise I tried eroding and dilating the images with cvErode() and cvDilate() but this is quite slow and if the moving objects on the screen are small the erosion deletes quite a bit to much of the object so after delating I don't always get a good result or splitted up objects.

After this I do a cvFindContours() to get contours, check on size and if it fits draw a rectangle around the moving objects. But results are poor because often an object is split into several rectangles due to the bad segmentation.

A friend now told me I might try using more than two following frames for the substraction since this might already reduce the noise... but I don't really know what he meant by that and how I should add/substract the frames to get an image that is almost noise free and shows big enough object blobs.

Can anybody help me with that? How can I use more than one frames to get an image that has as minimum noise as possible but with big enough blobs for the moving objects? I would be thankful for any tipps...

ADDITIONS:

I have uploaded a current video right here: http://temp.tinytall.de/ Maybe somebody wants to try it there...

This is a frame from it: The left image shows my results from cvFindContours() and the right one is the segmented image on which I then try to find the contours...

So one large objects it works fine if they are moving fast enough... i.e. the bicycle.. but on walking people it doesn't always get a good result though... Any ideas?

解决方案

Given three adjacent frames A, B, C you can get two frame differences X and Y. By combining X and Y (through, e.g. thresholding and then logical AND operation) you can reduce the effect of the noise. An unwanted side effect is that the motion-detected area will be slightly smaller than ideal (the AND operation will reduce the area).

Since image sequence motion estimation has been well researched for decades, you may want to read about more sophisticated methods of motion detection, e.g. working with motion vector fields. Google Scholar is your friend in that case.

这篇关于通过图像减法分割的优化算法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆