This sounds like it could be a job for OpenCV.
There have been a few ports to OpenCV for B4A over the years. There may be a function that allows you to isolate an object within an image – I'm not sure.
As someone else posted, this seems straightforward but it is an incredibly difficult problem.
Barry.