Why red ink vanishes under a red sheet, and how I made an iPhone do it
I work on Red Sheet at W Lab. Students in Japan write answers in red or orange pen, lay a sheet of red plastic over the page, and the answers disappear while the black questions stay. Slide the sheet down and you check yourself one line at a time. Red Sheet is an iPhone and iPad app that does this to a photo of your own notebook. This post is about the engine that finds the ink and hides it. Why…
The Red Sheet app on iPhone and iPad allows users to conceal handwritten answers by placing a red overlay over their notebook pages. This clever trick relies on understanding how red plastic filters light and how different colors interact with it. Red plastic lets red light through while blocking other colors, causing white paper and red ink to appear red, while black ink remains unaffected. Green highlighters, however, reflect almost no red light, appearing nearly black through the sheet and obscuring the text underneath.
Creating an iPhone app that replicates this effect requires more than just filtering the red channel from a photo. The app must accurately identify handwritten ink on various surfaces and lighting conditions. To achieve this, the app first adjusts for lighting by estimating the brightness of the paper background. It then separates ink from the paper using color analysis in the CIELAB color space, which better matches human perception.
Ink pixels are identified based on their distance from white and their chroma levels, while colored inks are clustered using k-means clustering to distinguish between different colors.
Next, the app distinguishes between handwritten pens and highlighters by analyzing their shapes. Pens are thin strokes with mostly empty bounding boxes, while highlighters are solid bands with mostly filled boxes. This shape-based classification ensures that pens are effectively hidden by the red overlay, while highlighters appear darker and block the text they cover.
The app then groups connected ink pixels into potential answers using a union-find algorithm and applies rules to identify individual answers based on their shape, size, and ink class.
Finally, the app renders the hidden ink on the screen. Hidden ink is masked and expanded to cover a slightly larger area, allowing the underlying paper color to show through and creating the illusion of erasure. The red overlay is applied last, completing the visual effect. This multi-step process works seamlessly on the iPhone, ensuring that answers remain hidden and intact until the user chooses to reveal them.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.