We made Pi work a lot until now. Let's send it on a well-deserved boating vacation. We are going to achieve it by applying a chroma key (green screen) effect to a picture of Pi with a scenic image as a background. First, we will load and display Pi with a green background:
from SimpleCV import * import time print 'Displaying Candidate Image' candidate = Image ('/home/pi/book/test_set/mypy.png') candidate.show() time.sleep(3)
This image is as follows:
Then, we will load and display the scenic lake background by using the following code:
print 'Displaying Background Image' lake = Image ('/home/pi/book/test_set/lake.tif') lake.show() time.sleep(7)
The scenic lake background will be displayed as follows:
Then, we will calculate the hue distance with hueDistance()
, and green as the hue color, and binarize it with the following code:
print 'Apply and display mask' mask=candidate.hueDistance(color=Color.GREEN).binarize() mask.show() time.sleep(7)
This will create...