I dont know what kind of algorithm you use to detect the shapes. Just adapt it in a way that it uses color information as well, to distinguish different colors with same brightness. One way might be to use your current algorithm individually on each of the 3 color channels and to fuse the 3 individual results to a common result in the end or in between.
For example, if your algorithm is:
- use sobel magnitude on grayscale image => img_sobel
- threshold img_sobel => img_thresh
- find contours in img_thresh
Then you could adapt it by:
- use sobel magnitude on R channel => r_sobel
- use sobel magnitude on G channel => g_sobel
- use cobel magnitude on B channel => b_sobel
- combine them by e.g. full_sobel = r_sobel + g_sobel + b_sobel or by full_sobel = max_per_pixel(r_sobel, g_sobel, b_sobel)
- threshold full_sobel => img_thresh
- find contours in img_thresh
But this is just an example. It depends on your actually used algorithm, how to adapt it for color images.