Add Bayer Filter to a PNG
Apply a realistic Bayer CFA mosaic pattern to any PNG image. Choose RGGB, BGGR, GRBG, or GBRG patterns with adjustable intensity and grid overlay.
About
Every digital camera sensor captures light through a Color Filter Array (CFA), most commonly the Bayer pattern invented by Bryce Bayer at Kodak in 1976. The sensor itself is monochrome. Each photosite records only one channel - R, G, or B - determined by a 2ร2 repeating tile. The full-color image you see is reconstructed through demosaicing algorithms that interpolate missing channels. This tool reverses that process: it takes a finished RGB image and strips it back to raw CFA data by zeroing the channels each pixel would never have captured. The result exposes the mosaic pattern a sensor actually "sees" before ISP processing.
This is useful for testing demosaicing algorithms, creating educational visualizations of sensor behavior, or generating realistic raw-simulation datasets. The tool supports all four standard Bayer orientations - RGGB, BGGR, GRBG, GBRG - and lets you control mosaic intensity from 0% (original) to 100% (pure CFA). Note: this approximation assumes ideal spectral separation with no crosstalk between photosites, which real sensors do not achieve.
Formulas
The Bayer mosaic operation for a pixel at position (x, y) in an RGGB pattern is defined piecewise:
With adjustable intensity ฮฑ โ [0, 1], the blended output becomes:
Where R, G, B are the original channel values at that pixel. ฮฑ = 1.0 produces a pure CFA mosaic. ฮฑ = 0.0 returns the unmodified image. Other Bayer orientations (BGGR, GRBG, GBRG) simply rotate the channel assignment within the 2ร2 tile.
Reference Data
| Bayer Pattern | Tile Layout (2ร2) | Green Ratio | Common Usage | Sensor Examples |
|---|---|---|---|---|
| RGGB | R G / G B | 50% | Most common, Canon default | Canon 5D IV, Sony A7 III |
| BGGR | B G / G R | 50% | Common alternative | Many Sony sensors, OnePlus |
| GRBG | G R / B G | 50% | Nikon primary pattern | Nikon D850, Fuji (non-X-Trans) |
| GBRG | G B / R G | 50% | Less common variant | Select Samsung sensors |
| X-Trans | 6ร6 tile | 55.6% | Fujifilm proprietary (not Bayer) | Fujifilm X-T5, X-H2 |
| Quad Bayer | 4ร4 tile | 50% | Pixel binning smartphones | Samsung GN2, Sony IMX766 |
| RGBW | 2ร2 with White | 25% | Low-light optimization | Huawei P8, some CCTV |
| Monochrome (no CFA) | N/A | 0% | Astrophotography, machine vision | Leica M Monochrom, ZWO ASI |
| Foveon X3 | Stacked RGB | 33.3% each | Full color per pixel (not mosaic) | Sigma dp Quattro, SD1 |
| CYGM | 2ร2 CYGM | 0% (Cyan/Yellow/Green/Magenta) | Legacy complementary color | Older Sony, JVC camcorders |
| Standard Bayer Green Weight | Any RGGB variant | 50% | Human vision has peak sensitivity at ~555 nm (green) | All standard Bayer sensors |
| Typical Pixel Pitch | N/A | N/A | Full-frame: ~4-8 ฮผm, Phone: ~0.6-1.2 ฮผm | Varies by generation |