I am trying to segment an object and its shadow in an greyscale image. The objects are light colored blobs while the shadow has darker colour. The background is typically somewhere between but there can be some random outcrops of low are high intensity pixels that would not calssify as objects. For example we have an original image with 2 visible white patches of lighter pixels and a perfect result would be to end up with all objects segmented but also associated with each other so that red patch is and actual object, blue patch is its “shadow” and yellow colour shows that both are associated.
I tried using Canny edge detection, clustering algorithms like Kmeans and DBSCAN as well as deep learning models YOLOv8 and Mask RCNN. The problem is that DBSCAN for example only reveals contours of the object. On the other hand machine learning approach is irregular and sometimes I end up with bounding boxes around just a shadow but it is still the best so far as I end up with with pretty exact coordinates of the objects on the image. I am asking for some direction, if there are some better methods or maybe if I should somehow combine these two? That might be inefficient but I am most concerned about detecting entire object as well as shadow and getting contours more or less correct. Maybe first apply YOLO and then some clustering?