AP CSA FRQ Guide

2012 FRQ 4: GrayImage

Count white pixels in a grayscale image and process pixels by subtracting values from diagonal positions when they exist.

2D Array Image Processing22 minute target2D arraysconstantsmutationbounds

Skills Tested

What this FRQ is really practicing

2D arraysconstantsmutationbounds

Treat these skills as the study checklist. If any tag feels shaky, review that topic before attempting the full written response.

Starter Approach

How to begin without copying a solution

  1. 1Count entries equal to the WHITE constant without changing the image.
  2. 2For eligible positions, subtract the down-two/right-two value and clamp to BLACK.

Write a first attempt before revealing any solution outline. Most AP CSA FRQ progress comes from tracing your own code and finding the missing case.

Common Mistakes

Mistakes to watch for while writing

Changing image values while counting white pixels.
Processing cells without a row + 2, col + 2 neighbor.
Letting pixel values become negative.

Self Check

Review questions before you submit

Traverses the 2D pixel array.

Use row and column loops.

Compares pixels to WHITE.

Use the class constant instead of a magic number when possible.

Uses the row + 2, col + 2 offset for processing.

Only process cells that have that diagonal neighbor.

Clamps negative results to BLACK.

Processed pixel values cannot go below BLACK.

Practice Links

Where to go next