Topic
The shape factor of an image is a mathematical description of the features of a target image. Based on the statistical range of the values of a specific shape factor, the features of the target image can be effectively determined, this provides an effective reference for Noise Removal. This section describes how to calculate the shape factor.
Image Edge Point Determination Method
In my blog post, the question of the target number (which has been solved, thank you for your advice) has been fixed, all vertices in the target region are recorded in a list. The number of image edge vertices is determined based on the decision algorithm.
To determine whether a point in an image in a connected area is an edge point, you only need to scan the eight adjacent regional points of the point, if any of the eight adjacent domain areas of the vertex is the background point, the vertex is the edge point.
For example:
Shape factor formula
The formula for calculating the shape factor is:
Where, S is the area of a connected area; L is its perimeter.
We can see from the above formula that if you want to obtain the shape factor of the cell area, you must first obtain the cell area and perimeter. For an area, calculate the number of pixels in each connected area.
For perimeter, the distance between two points in the horizontal or vertical direction is 1. The Euclidean distance formula is used for the distance between two points in the inclined direction:
Implementation
(1) scan a binary image, mark each connected area I, and calculate the sum of the number of pixels in each connected area, that is, the area S of the connected area.
(2) Calculate the perimeter of each region separately. Based on the chaincode principle, the following formula is used to calculate the perimeter:
N indicates the number of chaincodes, ne indicates the number of even chaincodes, and n0 indicates the number of odd chaincodes. Calculate the even and odd number chaincodes respectively, and count the even number of chaincodes and the odd number of chaincodes respectively, then, the product of the even number of chaincodes and the odd number of chaincodes is added to the product of 2, that is, the perimeter of the area.
Chaincode Principle
In the figure, four points a, B, c, and d are the four points in the image. They are distributed on a square with a unit length of 1, and the length between two points is in two cases.
1. The distance between ad, ac, bc, and db is the length of a square, that is, the length of one unit.
2. The formula for calculating the length between AB and dc is as follows: Lab = sqrt (a * c ).
Therefore, the formula for the perimeter of the area is as follows:
The variables are described above.
Conclusion
The shape factor of each connected area in the target image is counted, and a threshold value is determined based on the statistical results to determine whether the image is impurity or overlap. Therefore, calculating the image area and image perimeter is the basis for statistical shape factors.
For calculating and marking the target image in the connected area, go:
Question about the target number in image segmentation (solved. Thank you for your ideas)