Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

here's an idea:

  • make a mask for the blue and the red part using inRange
  • dilate both masks (make the blobs larger), until they start to overlap (they don't currently, that's the problem)
  • AND the masks to find the overlap
  • (optionally: erode the result again, or apply thinning)
  • use findNonZero() to retrieve the locations for the white overlap pixels

image description

and some code:

Mat mask_red, mask_blue;

inRange(ocv, Scalar(0,0,250), Scalar(0,0,255), mask_red);
inRange(ocv, Scalar(250,250,0), Scalar(255,255,0), mask_blue);
for (int i=0; i<5; i++) {
    dilate(mask_blue, mask_blue, Mat());
    dilate(mask_red, mask_red, Mat());
}
Mat final = mask_blue & mask_red;