use addWeighted for blending
authorAlexander Mordvintsev <no@email>
Mon, 4 Jul 2011 14:13:57 +0000 (14:13 +0000)
committerAlexander Mordvintsev <no@email>
Mon, 4 Jul 2011 14:13:57 +0000 (14:13 +0000)
samples/python2/watershed.py

index f35248a..5d45417 100644 (file)
@@ -31,7 +31,8 @@ class App:
     def watershed(self):\r
         m = self.markers.copy()\r
         cv2.watershed(self.img, m)\r
-        vis = np.uint8( (self.img + self.colors[np.maximum(m, 0)]) / 2 )\r
+        overlay = self.colors[np.maximum(m, 0)]\r
+        vis = cv2.addWeighted(self.img, 0.5, overlay, 0.5, 0.0, dtype=cv2.CV_8UC3)\r
         cv2.imshow('watershed', vis)\r
 \r
     def run(self):\r