Skip to the content.
Home Test Prep Project Documentation Create Task Documentation Final Review

Create Task Outline

Idea: RGB Student Photography Feature

Description: Rgb with grayscale feature that dynamically changes RGB values.

Overview of the CB “Create Performance Task”

Written Responses:
3a) The overall purpose of this program is to give students an opportunity to display photography in a fun and creative way. Students will be able to display their art in different color schemes, giving a different perspective on the work. It could also be part of an activity to create art and then greyscale it to get a final result. The functionality shown in the video is the user clicking the greyscale button turning the image grey as well as the user clicking the bluescale button which changes the photo to blue. Also, the artwork displays the name of the creator. The video demonstrates inputs and outputs. The input demonstrated here is the user clicking the button, being the input, and the image changing colors, being the output.
3b)

def image_data(path=Path(“static/rgb/“), img_list=None):  # info: path of static images is defaulted
    if img_list is None:  # info: color_dict is defined with defaults and these are the images showing up
        img_list = [
            {‘source’: “Ceramics 2”, ‘label’: “Nadira Haddach”, ‘file’: “lassen-volcano-256.jpg"},
        ]
  for img_dict in img_list:
        # to fix static images
        file = path / img_dict['file']
        print(file)

        img_reference = Image.open(file)
        img_data = img_reference.getdata()  # https://www.geeksforgeeks.org/python-pil-image-getdata/
        img_dict['format'] = img_reference.format
        img_dict['mode'] = img_reference.mode
        img_dict['size'] = img_reference.size

        # info: Conversion of original Image to Base64, a string format that serves HTML nicely
        img_dict['base64'] = image_formatter(img_reference, img_dict['format'])

        # info: Numpy is used to allow easy access to data of image, python list
        img_dict['data'] = numpy.array(img_data)
        img_dict['hex_array'] = []
        img_dict['binary_array'] = []
        # grayscale
        img_dict['gray_data'] = []

The name of the list being used in this code segment is “img_list”. The data in the list represents the image file displayed on the page. The list also consists of the source/label of the image, which is metadata about the image. The list manages complexity in my program by preventing repetition of the code segment for each reference. Without the list, the code would be much more confusing and unorganized. Each time the image was mentioned in the code, all of the list would have to be repeated, creating more room for error and making debugging a lot more difficult.

3c)

if len(pixel) > 3:
                # grayscale
                img_dict['gray_data'].append((average, average, average, pixel[3]))
            else:
                # grayscale
                img_dict['gray_data'].append((average, average, average))
<div>
                                <button type="button" id=myImage onclick="changeImage()">Color/Greyscale</button>
                            </div>

The identified procedure contributes to the program by giving the function of the page. The greyscale button is one of the main functionalities on the page, it gives the page purpose as without it the page would simply be html. The procedure allows users to change their image to different scales of color. The identified procedure works with backend python code from image.py, this code consists of averaging the data of each pixel of an image to create a grayscale image. This function is then called by the click of a button to switch the image to greyscale and back.
d)

<div>
                                <button type="button" id=myImage onclick="changeImage()">Color/Greyscale</button>
                            </div>
 <p hidden id="img_orig"></p>
                            <p hidden id="img_gray"></p>

The condition tested by the first call is if the button is clicked and the image is normal, the image will be changed to grayscale. On the other hand, the condition on the second call is if the image is already greyscale, the image will be reverted to the original. The result of the first call is the image changing to greyscale whereas the result of the second call would be the image changing to normal.