Calculation of the perimeter and area of the target object in color image
2020-05-07,,
, ,
(College of Physical Science and Technology, Shenyang Normal University, Shenyang 110034, China)
Abstract: Based on the boundary tracking method, the measurement of the area and perimeter of the objects in an image is designed in the paper. First, the method of digital image processing and its applications are elaborated, and then a method of color image conversion to grayscale image and binary image is introduced. On the basis of the binary image, based on the connectivity of the pixel spline, each area in the image is marked to get the number of areas. Then, contour extraction is carried out for each area of the image, based on the boundary tracking method. In order to improve the accuracy, the starting point of tracking is selected in the upper-left corner of the image and start a pixel-by-pixel scan, when it encounters the edge point, it starts tracking sequentially until it returns to the starting point. Finally, the area and perimeter of the objects are calculated based on the number of pixels. The algorithm in this paper is debugged and run in the VC++ 2010 compilation environment, and the results are given. The algorithm is simple and easy to implement, and the results are reliable.
Key words: color image; binary image; grayscale image; boundary tracking method; area marker
0 Introduction
Image processing is a technique to improve raw images which has been obtained with many sources such as cameras, sensors and so on. Image processing can be done in two methods.
Analog image processing is proceeded on analog analysis. Which includes processing two dimensional analog signals.
A digital image is a representation of a two-dimensional images as a finite set of digital values, called picture elements or pixels[1]. And the digital image processing is dealing with the developing a digital system that performs operations on a digital image. Digital image processing has two major duties, such as improvement of pictorial information for human interpretation and Processing of image data for storage, transmission and representation for autonomous machine perception. In this case, the contour extraction and area marking play significant roles in image processing. Area marking techniques are used in image processing, to separately identify the number of objects (regions) in complex images. And counter extractions method are used to track the boundaries of each objects (regions) in complex images.
The very first digital imaging applications were used in the newspaper industry in the years 1920[1]. In 1960s. The concept was developed with applications for medical imaging, character recognition, satellite imagery, photo enchantment etc. In the beginning, the purpose of image processing was to improve the quality of the image. Then the image processing included the image enchantment, restoration, coding and comparison. From the 1980s to today, digital imaging techniques have been used in different areas to fulfill various tasks, such as image enhancement/restoration, artistic effects, medical visualization, industrial inspection, law enforcement, human computer interfaces[1]. In the present the image processing is scattered the wings in different fields. Mainly in image sharpening and restoration, medical field, remote sensing, transmission and coding, machine/robot vision, color processing, pattern recognition, video processing, microscopic imaging, underwater image restoration and enhancement-etc[2-3].
1 Design of measurement method of target area and perimeter
In digital image processing, segmentation and measurement plays an important role. Under the measurement of objects, the identification of the area and the perimeter of the digital objects are significantly important.

Fig.1 System Design Flowchart
The object of this paper is to find out the way of getting the area and the perimeter of a digital object. The process has been followed by several steps. The main requirement for this process of calculating is to get the object in the binary format. Binary format of an image is to have the image in two basic colors such as Black and White.
The original image used was a color image. A color image cannot be directly converted in to a binary image. The first step of converting a color image in to a binary image is to get the gray scale image of the original color image. And then the gray scale image should be converted in to a binary image. Once the binary image is obtained the area or the perimeter can be measured.
The step by step procedure which was followed to obtain the target out come is given below in a flow chart in Fig.1. Illustrated procedure is explained below.
1.1 Convert the color image in to a binary image
Converting a color image in to a gray scale image is based on the three colors Red, Green and Blue. The main concept is to get the area pointers to the three values of Red, Green, and blue of the pixels and each byte corresponds to the brightness of the weighted R, G, B(Red, Green, Blue) and a pixel of the converted black and white image is represented by one byte of the grayscale value of the point, and its value lies between 0 and 255, the higher the value, the whiter the point, the brighter, the smaller the value, the darker[4]. In this process the following conversion formula was used:
Gray(i, j)=0.11×R(i,j)+0.59×G(i,j)+0.3×B(i,j)[6]
The color image was converted in to a gray scale one after this process. The next stepwas converting the obtained grayscale image in to a binary image. So the image for the further usage was only consist with the two primary colors, black and white.
After the color image converted in to the grayscale image the result was obtained was shown in the Fig.2 and Fig.3, After the grayscale image converted in to a binary image, the result was obtained as shown in the Fig.4 Image after binarization.

Fig.2 Original image

Fig.3 Image after gray scale transformation

Fig.4 Image after binarization
1.2 Mark the area of the binary image
In the binary image, the set of interconnected black pixels becomes the region of black. To find the number of regions in the image, this procedure was continued through the image for each region marking operation. Since the image has converted in to a binary image already, the pixels were eitherblack (0) or white (255), so the value of each pixel after external treatment was marked for the area of its external area. In here the method of judging the area with eight connections was adopted to mark the area of the image.
Following steps were followed to mark the area of the binary image: Scan from left to right, from top to bottom, one point at a time. If the pixels of the four points (upper-left, straight upper, upper-right and left front) are not objects, the number will be increased by 1, the array value is 1.
Priority order is the upper-right point, the straight upper point, the upper-left point and the front left point. The upper right-hand side has the highest priority and the left-front side has the lowest priority. If the upper-right point is an object, the current point is marked with the same value as the upper-right point.
If the upper right point is not an object, the straight upper point is determined. Special adjustment: If the current point’s upper-right and upper-left points for different markers, straight upper point and upper-left points are not objects, then the current point mark with the same value of the upper-right point. At this point, scan the image from beginning to end and mark all pixels with the same mark as the upper-right point with the same value. The method of judging the area with eight connection is describe using the example in Fig.5 algorithm of object identification, which is given below, the result of the area marking is show in Fig.6 and Fig.7

Fig.5 Algorithm of object identification

Fig.6 Original image

Fig.7 Result of the area marking
1.3 Implementation of contour extraction algorithm
Boundary tracking in image processing refers to starting from a boundary point in the image and searching for the next boundary point according to a certain identification standard to track the objective boundary in the image[11]. It collect the geometrical characteristic parameters through processing the object image, the extraction of target object contour has become the main factors influencing the accuracy of measurement[15]. The contour extraction algorithm based on boundary tracking method starts from a boundary point in the image, and then searches the next boundary point according to some discriminant criterion to trace the target boundary[4]. The center pixel can be tracked in 8 directions. The direction number and offset of each direction are determined as shown in Fig.8. The image is selected as the starting point of the leftmost pixel of the image. The tracking criteria are shown in Fig.9.

Fig.8 Center pixel tracking for 8 directions

Fig.9 The process of boundary tracking
1) When the starting point is found, record the point;
2) The initial tracking direction is: the upper left direction of 0;
3) To determine whether the point is the target point, is to make the point the starting point of the trace;
4) Rotate 90 degrees counterclockwise, as the new tracking direction, continue to detect the points in the new tracking direction.
5) If it is not the target point, rotate 45 degrees clockwise until the target point is found.
6) After finding the target point, on the basis of the current tracking direction, turn 90 degrees counterclockwise as the new tracking direction, and track the next boundary point by using the same method;
7) Continue the process until return to the starting point.
2 Implement the area and perimeter measurement
In the binary image, the set of the interconnected black pixels was grouped into a (black) area. on the basis of the section A though the marking operation of each pixel in the binary image, the pixel value of the object is changed to the mark, and the sum of the various labels were obtained, that is, the area of different areas are obtained.
In the binary image, a collection of connected black pixels becomes a black area. On the binary image area markers, through the marking of each pixel in the image, the pixel value of the object was changed to a label, and then the boundary tracking method was used to track the label of each black pixel of each closed area boundary outline line. The original image is shown in the Fig.10.
Then the final appearance of the result is shown in the Fig.11, which indicates the graphical representation of the area of each object in the image.
Then the final appearance of the result is shown in the Fig.12, which indicates the graphical representation of the perimeter of each object in the image.

Fig.10 The original image

Fig.11 The area of each object in the image

Fig.12 The perimeter of each object in the image
3 Conclusion
The main object of this paper was to find the area and the perimeter of the objects in a digital color image. The Visual Studio C++ 2010 software was used for the programming. Since the original image used was a color image, t he image was first converted in to a grayscale image and then again the gray scale image was converted in to the binary one. After completing that basic conversion, the image was ready for the area and perimeter calculations. As the next step the program was written to separately identify the boundaries and marking number of each object in the image. To calculating the area and perimeter of each object was written and the result was obtained in figures and also graphically. The result was also obtained in figures and graphically.
