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 if (getRed(px) + getGreen(px) < getBlue(px)+100 bgpx = getPixel(bg,x,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.

Computer Science & Information Technology

You might also like to view...

What would happen if the call to super.paintComponent were removed from the paintComponent method of the CoordinatesPanel class? Remove it and run the program to test your answer.

What will be an ideal response?

Computer Science & Information Technology

What happens when two objects with the same hashcode are added to a hash table?

a. They are stored in the same bucket/chain b. The old object will be overridden with the new object c. The new object won't be added to the structure d. An exception will be thrown

Computer Science & Information Technology

Gridify behaviors allow you to merge "drag and drop" copying with the Step and Repeat command.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

____ protects content creators against unauthorized use of their work.

A. Trademark B. Public domain C. Fair use D. Copyright

Computer Science & Information Technology