The principle applied here for area estimation is the Green's theorem. From the equation, the area (double integral) can be related to the its contour (line integral):
or in discrete form:
where Nb is the number of pixels in the contour of the area, and x and y are the coordinates on the contour.
For this activity, white shapes were created on a black background in Paint as sample images for area estimation. These images were loaded in Scilab (with SIP toolbox) using the imread function. The images were all generated in a truecolor image type. But for analysis, conversion to a binary (or black and white, 1 bit depth) image is necessary. The function im2bw was used for conversion using a threshold level of 0.5. This would produce an array of ones and zeros, where the ones would occupy the area of the shape.
From the binary image, the coordinates of the contour of the area must be determined. This can be done using follow. This function from the SIP toolbox outputs the x-y coordinates of the contour of the shape on the image. By obtaining this, the discrete formula for the area, shown above, can now be solved.
Now, the function follow obtains the coordinates on the shape, not the boundary of the shape, which is the one needed for area calculation in the formula. This can easily be corrected by adding 1/2 the number of the coordinates of the contour. The correction term can be justified because by considering the area of the coordinates of the contour itself, the formula above is simply adjusted by one, each for x and y. The adjustment translates to the pixels occupying the contour, which is actually the number of coordinates listed that the contour occupies.
The areas of the figures shown below were obtained and summarized in the following table. For comparison, the area of the shapes were obtained analytically, by taking the sum (sum function) of the binary image array of the shapes, since the area occupied by the shape in the array have values of 1, and others are 0. Moreover, the formula for the area of the regular shapes were also calculated based on the number of pixels defining the dimensions of the shapes.
or in discrete form:
where Nb is the number of pixels in the contour of the area, and x and y are the coordinates on the contour.
For this activity, white shapes were created on a black background in Paint as sample images for area estimation. These images were loaded in Scilab (with SIP toolbox) using the imread function. The images were all generated in a truecolor image type. But for analysis, conversion to a binary (or black and white, 1 bit depth) image is necessary. The function im2bw was used for conversion using a threshold level of 0.5. This would produce an array of ones and zeros, where the ones would occupy the area of the shape.
From the binary image, the coordinates of the contour of the area must be determined. This can be done using follow. This function from the SIP toolbox outputs the x-y coordinates of the contour of the shape on the image. By obtaining this, the discrete formula for the area, shown above, can now be solved.
Now, the function follow obtains the coordinates on the shape, not the boundary of the shape, which is the one needed for area calculation in the formula. This can easily be corrected by adding 1/2 the number of the coordinates of the contour. The correction term can be justified because by considering the area of the coordinates of the contour itself, the formula above is simply adjusted by one, each for x and y. The adjustment translates to the pixels occupying the contour, which is actually the number of coordinates listed that the contour occupies.
The areas of the figures shown below were obtained and summarized in the following table. For comparison, the area of the shapes were obtained analytically, by taking the sum (sum function) of the binary image array of the shapes, since the area occupied by the shape in the array have values of 1, and others are 0. Moreover, the formula for the area of the regular shapes were also calculated based on the number of pixels defining the dimensions of the shapes.
Regular shapes drawn in Paint as samples for area estimation: Square, Circle, Rectangle, Triangle and Oblong.
Irregular shape with the form "3rdy" as a trial for area estimation.
Table of the summary of the area estimation calculations. Units are in pixels.
Irregular shape with the form "3rdy" as a trial for area estimation.
Table of the summary of the area estimation calculations. Units are in pixels.
Notice the precision of the area estimation using Green's Theorem with that of the pixel count and shape area formula. For the regular shapes, the pixel count is exactly the same as the area from Green's theorem. The shape area formula have slight differences for some shapes perhaps due to the discrete image. The pixels have a rectangular (square) shape which is why for the square and rectangle shapes, the values are all the same. For the other shapes, the edges cannot be well defined so there are estimations resulting in the differences. Still, the results are very satisfactory. Even for the very irregular shape, a very accurate area estimate was exhibited.
The limitation for this technique mainly arises from the output of the function follow. The function assumes that there is only one object in the image that must be mapped, as stated in the Scilab SIP toolbox documentation. This is the reason why the irregular shape image presented does not enclose any object (such as inside the 'd') and all characters were connected. If this is not satisfied, only one object on the image would be mapped and a wrong area estimate would be obtained. Moreover, a digitized image also produces some error due to poor estimation of the edges of an object.
For this activity, I think I can give myself a grade of 10 since I think I did a good job in doing the activity and, together with some of my classmates, we determined some of the limitations and needed adjustments needed.
I would like to thanks Miguel Sison and Winsome Chloe M. Rara for significant discussions regarding this activity, especially with the limitations and adjustments for the technique. Also, this activity cannot be done without the guidance of our professors, Dr. Maricor Soriano and Dr. Gay Jane Perez.
The limitation for this technique mainly arises from the output of the function follow. The function assumes that there is only one object in the image that must be mapped, as stated in the Scilab SIP toolbox documentation. This is the reason why the irregular shape image presented does not enclose any object (such as inside the 'd') and all characters were connected. If this is not satisfied, only one object on the image would be mapped and a wrong area estimate would be obtained. Moreover, a digitized image also produces some error due to poor estimation of the edges of an object.
For this activity, I think I can give myself a grade of 10 since I think I did a good job in doing the activity and, together with some of my classmates, we determined some of the limitations and needed adjustments needed.
I would like to thanks Miguel Sison and Winsome Chloe M. Rara for significant discussions regarding this activity, especially with the limitations and adjustments for the technique. Also, this activity cannot be done without the guidance of our professors, Dr. Maricor Soriano and Dr. Gay Jane Perez.