top of page
Writer's pictureRene Jr Principe

Measuring Area from Images

Updated: May 26, 2020


BACKGROUND


Have you ever wondered how do we know how large our country is? Did someone actually had a trip to 7,641 islands and said, "Holy shiz I just measured Philippines to be 300,000 km²." How do we measure size anyway? Well, you can't just grab a ruler and measure everything you want to measure because guess what... it's impractical, and life is not that simple. With a little mathematics, I'll show you how area is estimated by image manipulation.

"Area measurement from images has application in cancer research (cancerous cells are generally bigger than healthy cells), remote sensing (estimation of land area) and automated product inspection (solder leads in circuit boards, grains) to name a few. Equations of area are known for regular, geometric shapes. However, in most real samples, shapes are arbitrary." - Maricor Soriano, A4 – Measuring Area from Images Activity Manual

In this activity, we employ Green's Theorem to perform contour integration for any closed convex curve. The premise is simply understood by segmenting a shape into "pie slices" and solve the area the analogous to how a triangle's area is calculated [1].


[INSERT FORMULAS]


IMPLEMENTATION


Synthetic (100 X 100) images of a circle, a rectangle, and a triangle as shown in Fig. 1 were generated in Python. The circle generated has radius of 40 pixels which means a theoretical area of 5024 square pixels, the rectangle which is 20 pixels long and wide covers 1600 square pixels and lastly, the theoretical area for the synthetic triangle is 1800 square pixels. Edge-detection algorithm was employed to the image array and the result is shown in Fig 2.


Figure 1. Synthetic images of basic geometric shapes.



Figure 2. CANNY edge-detection algorithm implemented to the synthetic images.


After successfully extracting the edges, the CANNY algorithm returns us a list of edge coordinates. Before proceeding to area calculation, it is important to note that the mathematical derivation requires two adjacent edges. It implies that we need to sort our list of edge coordinates such that it mimics the contour of the shape. One way to check if the coordinate list is sorted is to look up on an edge point's polar angle with respect to the centroid point. To employ this, I used numpy.arctan2. Shown in Fig. 3 is the calculated polar angle vs their index on the coordinate of the edge points of my synthetic circle. Evidently, edge-detected points adjacent to each other on the plot weren’t listed adjacent to each other on my coordinate list. I sorted the polar angles in an increasing manner as shown in Fig. 3 and saved the indices. The coordinate list was then sorted with respect to increasing polar angles using the saved indices.




122 views0 comments

Recent Posts

See All

Comments


bottom of page