Try doing chromakey in a range. The picture “statue-tower.jpg” has a blue, but not blue enough background to work with chromakeyBlue. However, if youchangetheruletogetRed(px) + getGreen(px) < getBlue(px)+100, it works great for the sky—but messes up near the ground.
Change chromakeyBlue to use the modified rule, and apply it to “statue- tower.jpg.”
```
def chromakeyBlue(source ,bg):
for px in getPixels(source):
x = getX(px)
y = getY(px)
if (getRed(px) + getGreen(px) < getBlue(px)+100):
bgpx = getPixel(bg,x,y)
bgcol = getColor(bgpx)
setColor(px,bgcol)
```
Now, write chromakeyBlueAbove to take in an input picture, a new background, and a number. The number is a y value, and you should only do chromakey to pixels above that input y. Apply it to “statue-tower.jpg” so that the blue of the sky gets changed to the moon or the jungle, but the area near the ground is not touched.
Note: Though the question says “pixels above that input y” it should read “pixels below that input y” in order for the sky to be affected but not the ground since y values get larger as you move down the picture.
```
def chromakeyBlueAbove(source ,bg, number):
for px in getPixels(source):
x = getX(px)
y = getY(px)
if y
bgcol = getColor(bgpx)
setColor(px,bgcol)
```
Note: The second part of the question does not state whether to use the old or modified rule, but using the old one would not have the proper effect on the sky.
You might also like to view...
A(n) ________ is an array name followed by an index enclosed in parentheses.
a) container b) subscript c) indexed array name d) position e) None of the above.
The television signal format used in France, Russia, and a few other countries is known as ____________________.
Fill in the blank(s) with the appropriate word(s).