User Rating 0.0 โ˜…โ˜…โ˜…โ˜…โ˜…
Total Usage 0 times
Drop image here or click to browse PNG, JPEG, WebP • Max 20 MB
RGGB pattern
Is this tool helpful?

Your feedback helps us improve.

โ˜… โ˜… โ˜… โ˜… โ˜…

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.

bayer filter color filter array CFA demosaic image processing PNG editor RGGB mosaic pattern raw image simulation

Formulas

The Bayer mosaic operation for a pixel at position (x, y) in an RGGB pattern is defined piecewise:

{
out = (R, 0, 0) if x mod 2 = 0 โˆง y mod 2 = 0out = (0, G, 0) if x mod 2 = 1 โˆง y mod 2 = 0out = (0, G, 0) if x mod 2 = 0 โˆง y mod 2 = 1out = (0, 0, B) if x mod 2 = 1 โˆง y mod 2 = 1

With adjustable intensity ฮฑ โˆˆ [0, 1], the blended output becomes:

pixelfinal = (1 โˆ’ ฮฑ) โ‹… pixelorig + ฮฑ โ‹… pixelbayer

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 PatternTile Layout (2ร—2)Green RatioCommon UsageSensor Examples
RGGBR G / G B50%Most common, Canon defaultCanon 5D IV, Sony A7 III
BGGRB G / G R50%Common alternativeMany Sony sensors, OnePlus
GRBGG R / B G50%Nikon primary patternNikon D850, Fuji (non-X-Trans)
GBRGG B / R G50%Less common variantSelect Samsung sensors
X-Trans6ร—6 tile55.6%Fujifilm proprietary (not Bayer)Fujifilm X-T5, X-H2
Quad Bayer4ร—4 tile50%Pixel binning smartphonesSamsung GN2, Sony IMX766
RGBW2ร—2 with White25%Low-light optimizationHuawei P8, some CCTV
Monochrome (no CFA)N/A0%Astrophotography, machine visionLeica M Monochrom, ZWO ASI
Foveon X3Stacked RGB33.3% eachFull color per pixel (not mosaic)Sigma dp Quattro, SD1
CYGM2ร—2 CYGM0% (Cyan/Yellow/Green/Magenta)Legacy complementary colorOlder Sony, JVC camcorders
Standard Bayer Green WeightAny RGGB variant50%Human vision has peak sensitivity at ~555 nm (green)All standard Bayer sensors
Typical Pixel PitchN/AN/AFull-frame: ~4-8 ฮผm, Phone: ~0.6-1.2 ฮผmVaries by generation

Frequently Asked Questions

Human vision has peak luminance sensitivity near 555 nm, which falls in the green spectrum. By allocating 50% of photosites to green, the Bayer CFA captures more luminance detail, which the human visual system uses for perceived sharpness. The red and blue channels contribute primarily to chrominance, where spatial resolution matters less perceptually.
Both contain the same ratio of color filters - 1R : 2G : 1B per 2ร—2 tile. The difference is the starting corner: RGGB places red at position (0,0), while BGGR places blue there. Choosing the wrong pattern when processing real raw data causes a color shift (reds become blues and vice versa). For simulation purposes on an already-demosaiced image, the visual difference is subtle but detectable at tile boundaries.
No. A real raw file contains single-channel sensor data plus extensive metadata (white balance coefficients, black level, linearization tables, lens correction profiles). This tool simulates the visual appearance of CFA mosaic data by zeroing non-selected channels in an RGB image. The output is still a standard 8-bit-per-channel image, not a 12/14-bit linear raw capture.
The intensity parameter ฮฑ linearly interpolates between the original pixel and the Bayer-filtered pixel. At ฮฑ = 0.5, each output channel equals 50% of the original value plus 50% of the CFA value. Channels zeroed by the Bayer mask contribute 0 in the CFA term, so they appear at half their original brightness rather than fully eliminated.
Each pixel retains only one of three color channels at full intensity. The other two are zeroed. Since perceived brightness is approximately 0.2126R + 0.7152G + 0.0722B (ITU-R BT.709), discarding two channels removes roughly 30-70% of luminance per pixel depending on which channel survives. Green pixels appear brightest because green dominates the luminance equation.
Yes, when enabled, the grid lines are composited directly onto the output pixel data before export. Each grid line is rendered as a semi-transparent overlay at CFA tile boundaries (every 2 pixels). For clean CFA data without annotation, disable the grid overlay before downloading.