JMU
logoPerspecTV.png
Going Further on Programming Assignment 6


These questions/problems/tasks allow you to go further on Programming Assignment 6. They are neither required nor for extra credit. They will, however, help you gain a deeper understanding of the material.

In this case, your job is to develop an application that can enhance a particular yard line on a football field.

1 Existing (Working) Components: The Camera class has methods for getting the Color of the grass, for getting the Color to use when enhancing the first down line and the line of scrimmage, and for getting the top (getTop()) and bottom (getBot()) point of a given yard line. Yard lines are designated by the yard number and an 'R' or 'L', indicating whether the yard line is to the right or left of the 50 yard line. So, for example, "48R" indicates the 48 yard line to the right of the 50 yard line.

In addition, the MarkitY class has the main() method for the application. You must not modify it.

MarkitY ( Source Code )

The execution of MarkitY is controlled with command line parameters that contain: the name of the file containing the frame/image, the line of scrimmage, and the first down line.

2 New Components: You must create a YardMarker class that is similar in spirit to the BillboardMarker class. It must have a method with the following signature:
    /**
     * Enhance the given yard line using the given color.  That is
     * "draw" a line that is 19 pixels wide centered 
     * at the given yard line.
     *
     * The line that is drawn must only replace pixels that are
     * similar to the current grass color.
     *
     * @param image      The original image
     * @param yardline   The yard line to enhance
     * @param Color      The color to use for the enhancement
     * @return           A copy of the image with the yard line enhanced
     */
    public Color[][] enhance(Color[][] image, String yardline, Color line)
  
3 Testing: The following execution of the application:
      java MarkitY field.png 43R 48R
      

must generate a result like the following:

expected-field-43R48R.png
4 Improving the New Components: Replacing the color in the image with the line color results in an enhanced image that looks somewhat artificial. The appearance of the result can be improved by taking a weighted average of the red, green, and blue components of the source color and the line color (e.g., a 60/40 weighting usually works well). The red, green and blue components can be obtained from a Color object using the obvious accessors. These values will be in the interval [0,255]. The Color class has a constructor that must be passed red, green and blue values. These values, too, must be in the interval [0,255] so care must be taken when calculating the weighted averages.

This approach yields results like the following:

expected-field-43R48R-blended.png

Modify your enhance() method so that it uses this approach.

Copyright 2011