图像中的对象方向 [英] Object Orientation in an image

查看:127
本文介绍了图像中的对象方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的任务是简单地找到图像中对象的方向.

我们能够找到一种算法,该算法涉及使用图像的矩.问题是我们对结果感到困惑...

我们拥有的代码如下:

获得时刻

we were tasked to simply find the orientation of an object in an image.

we were able to find an algorithm which involves using the moments of the image. problem is that we were confused with the results...

the codes we have are as follows:

FOR GETTING THE MOMENTS

public void getMoments()
        {
            int temp = 0;
            for (int x = 0; x < picture.Width; x++)
            {
                for (int y = 0; y < picture.Height; y++)
                {
                    temp = getIntensity(x, y);
                    m00 += temp;
                    m10 += x * temp;
                    m01 += y * temp;
                    m20 += Math.Pow(x, 2) * temp;
                    m02 += Math.Pow(y, 2) * temp;
                    m11 += x * y * temp;
                }
            }
            u11 = m11 - ((m10 * m01) / m00);
            u20 = m20 - ((m10 * m10) / m00);
            u02 = m02 - ((m01 * m01) / m00);
        }



获取方向



FOR GETTING ORIENTATION

public double computeOrientation()
       {
           getMoments();
           theta = (double).5 *Math.Atan((2 * u11) / (u20 - u02));
           toDegrees();
           return theta;
       }







are our codes wrong somewhere?

推荐答案

您可以对不同的方向使用不同的空间过滤器.如果您为3 x 3或5 x 5内核在垂直方向上赋予权重,则它会掩盖所有内容,但仅显示垂直线,即力矩的计算将仅在一个方向上加权.水平,对角线等的相同方法,在每个滤镜操作中分配不同的颜色.您将获得漂亮的边缘.这种空间滤波器之一是索贝尔边缘滤波器. http://www.roborealm.com/help/Sobel.php [ http://accord-net.origo.ethz.ch/ [<具有预定义功能的href ="http://accord-net.origo.ethz.ch/" target ="_ blank" title ="New Window"> ^ ].

那里有很多复杂的高科技面向对象的图像分割算法.我给出的是一个简单的想法.
You may use different spatial filters for different directions. If you give weights on the vertical for 3 x 3 or 5 x 5 kernel it masks everything but only shows the vertical lines i.e computation of moments will weighted for only one direction. Same way for horizontal, diagonal etc., assign different color at each filter operations. You will get nice edges. One of such spatial filter is sobel edge filter. http://www.roborealm.com/help/Sobel.php[^]Now you may compute your algorithm how to handle those edges, because an object can have a horizontal, vertical or any angle lines. You have to have an algorithm to find the major axis of it.

Accord .Net is a free library in c# http://accord-net.origo.ethz.ch/[^] which has predefined function which may be useful.

Lot of sophisticated high tech object oriented image segmentation algorithms out there. What I given is a simple idea.


恐怕您没有描述您的问题. 我们对结果感到困惑"是什么意思??

您确实在计算惯性椭圆的方向.如果图像是二进制的(黑色背景上的白色物体)或接近该图像,这是有道理的.

您的公式看起来还不错.一些累加器可能溢出(如果它们是整数).

您对toDegrees的调用是可疑的,它没有参数.所以我怀疑theta是否以度为单位返回.

并且请避免使用Math.Pow(x, 2),而是使用x * x,更快,更准确.
I am afraid you didn''t describe your problem. What do you mean by "we were confused with the results" ???

You are indeed computing the orientation of the ellipse of inertia. This makes sense if the image is binary (white object over a black background) or close to that.

Your formulas look ok. Some of the accumulators can overflow (if they are integer).

Your call of toDegrees is supicious, it has no argument. So I doubt that theta is returned in degrees.

And please, avoid Math.Pow(x, 2), use x * x instead, faster and more accurate.


这篇关于图像中的对象方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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