Carter A. answered 04/16/20
Experienced software developer using object-oriented Java
Here is a simple, but not very efficient, approach. Determine a rectangle that contains all the points in the shape. Iterate through all the pixels in the rectangle and count the number that are inside the shape. Some smarter way might be possible if the shape is convex, but I don't see how it could work with topologically different shapes like a donut, double donut, etc.
So to solve your problem, determine a rectangle that encloses both shapes. Iterate through the pixels and count the number that are inside both shapes.