怎么能用c#做区域增长? [英] how can ı do region growing with c#

查看:74
本文介绍了怎么能用c#做区域增长?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

怎么能用c来做地区的成长#
$ b $bı有一个源代码
$ b $bı需要帮助

how can ı do region growing in ımage with c#
ı have a source code
ı need help

推荐答案



区域可以由矩形(Rectangle和RectangleF),GraphicsPaths或RegionData组成。区域可以与矩形(Rectangle和RectangleF),GraphicsPaths或其他Region联合。在形成两个或多个区域的联盟的情况下,重要的是使接收区域为空。


Regions can be made up of Rectangles (both Rectangle and RectangleF), GraphicsPaths, or RegionData. A Region can be "unioned" with Rectangles (both Rectangle and RectangleF), GraphicsPaths, or another Region. In the case of forming the Union of two or more Regions, it is important to make the receiving Region empty.



在下面的例子中,我们有一个包含标签的矩形数组。我们想对任何标签上的MouseClick事件作出反应(稍后我们将确定MouseClick发生在哪个标签上)。区域是命中测试的完美数据结构。所以我们想要一个包含构成标签的所有矩形的Region。假设已经填充了标签矩形数组。


In the following example, we have an array of Rectangles that contains labels. We want to react to a MouseClick event on any of the labels (later we would determine on which label the MouseClick occurred). A region is the perfect data structure for hit testing. So we want a Region that contains all of the Rectangles that make up labels. Assume that the array of label Rectangles has already been populated.

Rectangle [ ] label;

// ******************************************* new_label_union

Region new_label_union ( )
    {
    Region  region = new Region ( );

    region.MakeEmpty ( );
    for ( int i = 0; ( i < label.Length ); i++ )
        {
        if ( label [ i ] != null )
            {
            if ( label [ i ] != Rectangle.Empty )
                {
                region.Union ( label [ i ] );
                }
            }
        }

    return ( region );
    }



请注意,一旦我们创建了Region,我们就会将其设为空。虽然Region.Union(Rectangle)不是必需的,但Region.Union(Region)绝对是必需的。所以我总是使用Region.MakeEmpty。


Note that as soon as we create the Region, we make it empty. Although not necessary for Region.Union ( Rectangle ) it is absolutely necessary for Region.Union ( Region ). So I always use Region.MakeEmpty.



希望有所帮助。


Hope that helps.


这篇关于怎么能用c#做区域增长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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