Your task is to take a 24 BPP sRGB image and output the same image upscaled 3x into red, green, and blue subpixels. The resulting image will be made entirely of pure black, red, green, and blue pixels.
Each pixel from the source image, when zoomed, produces an arrangement of 9 sub-pixels that can be either on or off (i.e. their respective color or black). The specific arrangement uses three columns of red, green, and blue, in that order, like so:
(Note that the borders on these "pixels" are for demonstration only.)
Since each of the nine subpixels can only be on or off, you will have to quantize the input image and use different subpixel patterns to achieve 3 levels of brightness.
For each subpixel in the image:
- For color levels 0-74, all subpixels should be black.
- For color levels 75-134, the middle subpixel should be the respective color and the other two should be black.
- For color levels 135-179, the middle subpixel should be black and the other two should be the respective color
- For color levels 180-255, all three subpixels should be their respective color
I chose these level ranges because those are what happened to look good
Apply this transformation to every pixel in the image and output the subpixel-upscaled image.
Single-pixel examples
rgb(40, 130, 175) will produce this pattern:
rgb(160, 240, 100) will produce this pattern:
Full Image Examples
Images sourced from Wikipedia
Rules and notes
- Input and output may be in any convenient format, whether that's actual image files or (possibly nested) lists of RGB values.
- You may assume the pixels are in the sRGB colorspace with 24BPP.
Happy golfing!