1、matlab图像变换应用(Application of MATLAB image transformation)MATLAB image processing toolbox - regionpropsMatlab and Image 2009-12-07 14:14:39 reading 704 comment 0: large and medium subscriptionsRegionprops is a function used to measure the attributes of different regions in an image.The representation
2、is: stats=regionprops (L, properties)A series of attributes in each region of the annotation matrix L are measured. Different positive integers in L correspond to different regions, for example, L is equal to the integer 1, the corresponding region is 1; L is equal to the integer 2, the element corr
3、esponds to region 2; and so on. The return value STATS is a structure array of length max (L (:), and the corresponding field of the structure array defines the measure under the corresponding attributes of each region. Properties can be a comma separated string list, a string array full of strings,
4、 a single stringallorbasic. If properties is equal to the stringall, is a list of all the measurement data in the string will be calculated, if properties is not specified or equal tobasic, thenArea,Centroid, and attribute:BoundingBoxwill be calculated. The following list is all valid property strin
5、gs, which are case sensitive and can be abbreviated.AreaIt is scalar, and the total number of pixels in each region of the image is calculated. Note: this value may be slightly different from the value calculated by the function bwarea. For such a value, we can use it by dividing the number of pixel
6、s in the entire image region as the candidate feature of pattern recognition.BoundingBoxIt is the vector of the 1 row ndims (L) *2 column, that is, the smallest rectangle containing the corresponding region. BoundingBox is ul_corner width, ul_corner x Y Z here to. A bounding box coordinates are give
7、n in the form of the upper left corner of the boxwidth, x_width y_width. pointed out that the boundary box length along each dimension.CentroidThe vector of the 1 row ndims (L) column, and the centroid of each region (Zhong Xin) is given. Notice: the first element of Centroid is the horizontal coord
8、inate of gravity center (x coordinate), and the second element is the vertical coordinate of gravity center (Y coordinate). Centroid all other elements are arranged in the order of dimension.MajorAxisLengthIt is the length of the ellipse of the scalar, which has the same standard two order central m
9、oment as the region (in the sense of pixels). This property supports only two-dimensional annotation matrices.MinorAxisLengthIt is the length of the ellipse of the scalar, which has the same standard two order central moment as the region (in the sense of pixels). This property supports only two-dim
10、ensional annotation matrices.EccentricityIt is the eccentricity of the ellipse which has the same standard two order central moment as the region and can be used as the characteristic. This property supports only two-dimensional annotation matrices.OrientationIs a scalar, ellipse with the same stand
11、ard two order central moment and regional long axis and X axis angle (degrees). This property supports only two-dimensional annotation matrices.ImageTwo valued image, the logical matrix with the same size as a region. You can use this property to extract each sub region directly, and then do the cor
12、responding processing!FilledImageAnd the only difference is that its a logical matrix for filling! There is no difference between this case and the upper one, and only when there is a hole in the area can the difference be obvious.FilledAreaIs scalar, filling the number of on pixels in the region im
13、age.ConvexHullIt is the matrix of 2 rows of P, which contains the smallest convex polygon of a region. Each row of this matrix stores the XY coordinate of the vertex of this polygon. This property supports only 2 dimensional annotation matrices.ConvexAreaThe number of on pixels in a convex polygon i
14、mage is filled with scalars.EulerNumberScalar,A topological invariant in geometry topology - Euler number, equal to the number of objects in the image, minus the number of holes in these targets. This property supports only 2 dimensional annotation matrices. The Euler numbers in this case are 1.Extr
15、ema8 Row 2 column matrix, eight direction region extreme point. Each line of the matrix stores the XY coordinates of these points, and the vector format is top-left top-right right-top right-bottom bottom-right bottom-left left-bottom left-top. This property supports only 2 dimensional annotation ma
16、trices.EquivDiameterScalar, equivalent diameter: the diameter of a circle with the same area as that of a region. The formula is as follows: sqrt (4*Area/pi). This property only supports 2 dimensional annotation matrix. In this case, the 12 region diameter vector is normalized:SolidityScalar is the
17、ratio of pixels in the region and its smallest convex polygon. The calculation formula is: Area/ConvexArea, which is also an affine feature, in fact, reflects the degree of the degree of dependency of the region. This property supports only 2 dimensional annotation matrices. In this case, the 12 reg
18、ion convex element proportion vector is:ExtentScalar is the ratio of pixels in the region and its minimum boundary rectangle. The calculation formula is: Area is divided by the area of the boundary rectangle, which is also an affine feature, which actually reflects the extent of the expansion of the
19、 region. This property supports only 2 dimensional annotation matrices. No more calculations are given!PixelIdxListP meta vector, index index of storage area pixels.PixelListP rows ndims (L) column matrix, store the pixel coordinates corresponding to the above index.Be careful:The input label matrix
20、 L can have any numeric type.Comma separated list syntaxWhen you design algorithms based on the output of the regionprops function, the use of comma splitting list syntax highlights its very value. For example, for a stored scalar attribute, you can use this syntax to create a vector containing the
21、value of this property in different regions of the image. For example, the following two sentences are equivalent:Stats (1).Area, stats (2).Area,., stats (end).AreaStats.Area therefore, you can use the following methods to create the corresponding vectors:Regionprops (L,Area);AllArea = stats.Area;Al
22、lArea is a vector with the same length as the structure array stats.Regional choice based on specific principlesWhen you want to choose a region based on specific criteria, it is useful to combine function ismember with regionprops. For example, create a two value image with an area greater than 80,
23、 and use the following commandsIDX = find (stats.Area 80);BW2 = ismember (L, idx);Computational performance considerationsMost of the measurement times of attribute measurement are very few, except for the attributes that depend heavily on the number of regions and the number of pixels in the image
24、L. For example:ConvexHullConvexImageConvexAreaFilledImageIn addition, it is recommended that all attribute values be calculated at once, because separate calculations are similar to the same computation time!Working with two valued imagesBefore calling regionprops, the two valued image must be trans
25、formed into a label matrix. Two functions can do that:L = bwlabel (BW); L = double (BW); note: Although these two functions generate different annotation matrices from the same one or two valued image, they are equivalent! For example, the following two valued matrix BW is given,11000011000000000000
26、0011000011Bwlabel creates a continuous region labeling matrix containing two integers labeled by integers 1 and 2, respectivelyMylabel = bwlabel (BW)Mylabel =110000110000000000000022000022Double creates a discontinuous region labeling matrix that is marked by integer 1.Mylabel2 = double (BW)Mylabel2 =110000110000000000000011000011Regionprops is not responsible for automatically converting two valued image data types, but you decide which data conversion method to use to store the data you want.