find a line go through the center mass and that line must be inside object area
How about:


Separate the foreground from the background and keep a list of indices or a logical mask from the background
Convert the image to a (rho, theta) coordinate space, meaning that each pixel is encoded by the angle and length of vector from the origin to itself. You can scan along this vector to see if you encounter any background pixels. Have a look at the so-called Trace Transform
Alternatively you can stay in the original coordinate domain and use Bresenham's line algorithm to get all pixels belonging to a scan-line between a point and the center and then comparing them against the list of background labeled pixels.


Perhaps you can optimize a bit by starting on the edge of the foreground shape, working your way inward to the center, discarding any scan-line the moment it encounters a background labeled pixel.