Red and blue markers look wrong after removing one column from an otherwise correct machine-vision image. Determine whether cropping happened before or after demosaicing. A raw Bayer sample's color depends on its array index. Moving the origin by one row or column can change the first color despite preserving the scene.
Use owned offline assemblies, synthetic color charts, and raw data. Do not use people's images or change field equipment. Verify camera output, crop metadata, and display separately. Frame rate and resolution do not qualify Bayer interpretation.
Bayer raw samples are not full RGB pixels
A Bayer color filter array repeats across two rows and two columns. Each location measures only one filtered component, and neighboring samples are needed to reconstruct full red, green, and blue. In RGGB, the first row starts red then green and the next starts green then blue. The four-cell order needs a defined origin. The label Bayer alone does not identify the first color a decoder receives.
The cropped buffer normally starts again at local row and column zero, which still map to one cell in the full image. Changing just the dimensions and retaining the full-frame color order can mislabel that first cell. A shift by two positions along an axis returns the two-by-two pattern to the same phase along that axis. Phase depends on the parity of the origin.
Some cameras and libraries update the format after rewriting the region or changing orientation. Other models restrict region starts to even positions or larger increments. A program may also retain full-frame coordinates internally and need no second crop correction. Determine who cropped the image and whether reconstruction receives a format flag, full-frame coordinates, or an already translated local phase.
Four parities can produce four patterns at equal dimensions
Assume a synthetic full frame starts with RGGB, repeating a red-green row and a green-blue row. Use zero-based full-frame coordinates, with a horizontal and vertical origin. The example includes no mirroring, rotation, pixel binning, or device remapping.
| Horizontal offset | Vertical offset | Local two-row pattern |
|---|---|---|
| Even | Even | Red-green, green-blue, RGGB |
| Odd | Even | Green-red, blue-green, GRBG |
| Even | Odd | Green-blue, red-green, GBRG |
| Odd | Odd | Blue-green, green-red, BGGR |
Moving x from 100 to 101 changes red to green even at width 640. With y also incremented by one, the phase becomes blue. Moving from 101 to 103 keeps odd parity. The four cases are two horizontal and two vertical options, not device configuration guarantees. Test odd crops offline if hardware disallows them.
Distinguish incorrect phase from white balance or transport
Keep full raw data and camera format. Compare full demosaic, a pre-demosaic odd crop, and a crop of the reconstructed RGB image. A crop after reconstruction cannot change pixel channel meanings. If only the raw crop changes color, verify the demosaicer's origin rather than adjusting white balance.
Verify first- and second-row organization, including stride, packing, and active width. Incorrect byte boundaries can also corrupt an image. Establish correct unpacking before assigning a filter color to any pixel. A correct byte count does not establish the row color order, and a correct order does not qualify bit depth or transfer integrity.
Check whether the application adjusts the phase twice. A reconstruction call may already know the parent image and ROI coordinates, or the driver may supply a revised array flag. If the host then shifts the phase manually, it can corrupt already correct input. Record the camera declaration, actual host crop, and reconstruction input separately. For each stage, state whether it uses full-frame coordinates, local first-cell phase, or an already reconstructed color image.
Qualify camera data and the reference separately
SCTF's SX2M24.000E20F30THN from mainland China is a candidate for an active 24 MHz, 1.2 V CMOS input. Confirm full code, power, output, package, load, and destination. It identifies no installed part. An origin-parity fault needs data-path evidence. Missing raw data warrant a separate capture review.
Request the actual output Bayer order, permitted ROI-origin increment, whether mirroring or rotation changes the format indicator, and where that indicator is readable. Compare the documentation with a clearly identified synthetic color chart at several origins. Equal dimensions show only that the images contain the same number of pixels. Using the same red and blue targets also does not show that each cropping stage uses the same coordinates. Document the camera and host definitions of the upper-left corner.
For comparisons across models or lots, include the original raw file and its interpretation settings with the color chart image. If the camera supports only fixed even offsets, do not make a manually invented odd hardware setting a condition of acceptance. Verify any application-side raw crop separately. If the current unit outputs a color image and a later lot uses a raw mode, do not assume that each raw pixel already represents all three color channels.
Frequently asked questions
Why does phase change without a size change? A one-pixel origin change shifts the pattern while leaving area constant.
Can swapping red and blue fix it? An odd shift can make the origin green. Verify actual Bayer phase and the reconstruction stage before remapping.
