Matlab函数imfeature详解

Matlab函数imfeature详解

初学者请多多指正。

 但凡读matlab程序遇到的不了解的函数一除了上网搜索外,matlab中的help和命令行的help也能够提供很大的帮助尤其是help菜单,有详细的解释和举例。今天想把一个车牌识别的程序运用到表格识别中,遇到imfeature函数。没见过,于是help imfeature

得到的是

 IMFEATURE Compute feature measurements for image regions.

    Note: This function isobsolete and may be removed in

    future versions. UseREGIONPROPS instead.

   

    STATS =IMFEATURE(L,MEASUREMENTS) computes a set of

    measurements for eachlabeled region in the label matrix

    L. Positive integerelements of L correspond to different

    regions. For example, theset of elements of L equal to 1

    corresponds to region 1;the set of elements of L equal to 2

    corresponds to region 2;and so on. STATS is a structure

    array of lengthmax(L(:)). The fields of the structure array

    denote differentmeasurements for each region, as specified

    by MEASUREMENTS.

 

    MEASUREMENTS can be acomma-separated list of strings, a cell

    array containing strings,the string 'all', or the string

    'basic'. The set of validmeasurement strings includes:

 

      'Area'             'ConvexHull'   'EulerNumber'

      'Centroid'         'ConvexImage'   'Extrema'

      'BoundingBox'      'ConvexArea'    'EquivDiameter'

      'MajorAxisLength'  'Image'         'Solidity'

      'MinorAxisLength'  'FilledImage'   'Extent'

      'Orientation'      'FilledArea'    'PixelList'

      'Eccentricity'

 

    Measurement strings arecase insensitive and can be

    abbreviated.

 

    If MEASUREMENTS is thestring 'all', then all of the above

    measurements arecomputed. If MEASUREMENTS is not specified

    or if it is the string'basic', then these measurements are 

    computed: 'Area','Centroid', and 'BoundingBox'.

 

    STATS =IMFEATURE(L,MEASUREMENTS,N) specifies the type of

    connectivity used incomputing the 'FilledImage',

    'FilledArea', and'EulerNumber' measurements. N can have a

    value of either 4 or 8,where 4 specifies 4-connected objects

    and 8 specifies8-connected objects; if the argument is

    omitted, it defaults to8.

    Class Support

    -------------

    The input label matrix Lcan be of class double or of any

    integer class.

 

    See also bwlabel,ismember.

 

这段英文的意思是imfeature是用来图像区域的特征的。但是这一函数已经过时了并且在未来的版本里会被移除,建议用regionprops来代替。

怎么用呢?如何设置各个参数?参数的意思?

 句式一: STATS =IMFEATURE(L,MEASUREMENTS),L是已经标记好的标签矩阵(可以通过bwlabel得到,这函数也过时了,汗!)MEASUREMENTS是指定的各个属性可以有如下

'Area'    (面积)         'ConvexHull'    'EulerNumber'

     'Centroid'  (质心)       'ConvexImage'   'Extrema'

      'BoundingBox'  (边框)   'ConvexArea'    'EquivDiameter'

      'MajorAxisLength'  'Image'         'Solidity'

      'MinorAxisLength'  'FilledImage'   'Extent'

      'Orientation'      'FilledArea'    'PixelList'

      'Eccentricity'

也可以是'all',(上述所有属性都测量)'basic'(也是默认情况只计算标注中文的那三个)。

句式二;STATS= IMFEATURE(L,MEASUREMENTS,N),是用在计算'FilledImage',

'FilledArea',  'EulerNumber'时(?)N可以指定四连接和八连接

得到的STATS是啥呢?得到的是最大可达L所有元素数的结构数组(这是啥?类似C语言 的。)结构体中的每一元素代表着每一的不同属性。

重点说一下BoundingBox,这就是包围所有区域的最小矩形,在matlab中是一个1*Q*2的矢量,其中Q是矩形框内的区域数,是这个形式[ul_corner width],ul_corner:指定左上角的坐标,形式[x y z ...],而width则是区域每一维的宽度,形式[x_width y_width ...]。

举例说明一下:

[L,num] = bwlabel(bg2,8); %标注二进制图像中已连接的部分

Feastats = imfeature(L,'basic'); %计算图像区域的特征尺寸

Area=[Feastats.Area];%区域面积

BoundingBox=[Feastats.BoundingBox]; %[xy width height]车牌的框架大小

这里Q=4,

Feastats是<4x1 struct>

每一个struct包含三个Field

BoundingBox:

116.500000000000    159.500000000000    32  20  (粉红)

176.500000000000    136.500000000000    21  24  (黄)

205.500000000000    30.5000000000000    32  27  (橙)

224.500000000000    215.500000000000    99  39  (深粉红)

 

 

 

 

 

 

 

你可能感兴趣的:(matlab,imfeature)