Ask Your Question

Revision history [back]

So here is the solution: Using the first image

  1. Find edges using cv::Canny
  2. Find Contour point from these edges using cv::findContours with CV_RETR_CCOMP flag (this method also returns a hierarchy array)
  3. For all contours ignore if the contour is an edge (hierarchy[3] != -1)
  4. For all valid contours find the color value in the second and third image posted in question and categorize them (use your own data structure to save that information)
  5. Assign new colors to pixels inside contours based on their cattegory
  6. Apply smoothing and you final image is ready