A simple implementation of a MonteCarlo algorithm in Python. A MonteCarlo algorithm utilizes randomization in order to approximate an answer in cases where the perfect answer may be impossible to find.
Feed this a 1-bit (2 color) black and white image like the one below and it will calculate the % area of black color. This allows you to approximate the area of weird 2D shapes not defined by equations. Just multiply the area of the image you feed this by the % result you get at the end, and you'll get an approximation of the weird shape's area.