Roberts Cross Measures Two Diagonal Pixel Differences
2026-11-26

Roberts Cross Measures Two Diagonal Pixel Differences

A Roberts cross filter measures local grayscale changes with just four samples. Put the samples in a two by two block and subtract across each of its diagonals. Both differences describe the same neighborhood, centered where the diagonals cross. In a small worked image this distinction between the response's geometric location and its storage index is visible. It matters when comparing an edge map against the original pixels or another map drawn on the same screen.

Take two signed differences at one crossing

Use A for the upper left sample, B for the upper right, C for the lower left and D for the lower right. Define g1 as A − D and g2 as B − C. This convention subtracts the lower endpoint from the upper endpoint on each diagonal. The signs are meaningful if the two differences are kept separately. A convolution implementation can flip displayed kernel signs because convolution reverses the offsets. Compare the implementation's sign convention before combining its directional outputs with another calculation.

Take a block whose first row contains 16 and 58, and whose second row contains 22 and 64. The first diagonal difference is 16 − 64 = −48. The second is 58 − 22 = +36. A zero output on either diagonal can occur in a neighborhood that still changes on the other. A constant block gives zero on both. Adding the same scalar to every sample likewise leaves both differences unchanged, provided that the operation preserves the four values without clipping.

The first diagonal gives minus 48 and the second yields plus 36, with magnitude 60.
The crossing marks the midpoint of both sample pairs. Source: Zhilianhai editorial desk, original AI-assisted conceptual illustration.

State how the edge magnitude is scaled

One convenient score is the Euclidean magnitude √(g1² + g2²). The worked block gives √(2304 + 1296) = 60 in intensity difference units. The scikit-image implementation at the cited release combines the two responses with a division by √2 after taking their Euclidean magnitude. On the same numeric scale the corresponding value is about 42.43. If input conversion rescales values to a unit interval, the output scales too. To reproduce a numeric threshold, keep both the definition of the score and the input intensity scale in the record.

The diagonal of a square with one-pixel side length is √2 pixels long. Dividing each diagonal difference by that length produces a directional slope per pixel. The two diagonal directions are perpendicular in a square grid. The unnormalized score in the worked example is described simply as a difference score. Treat pixel spacing and units separately when the grid represents a physical length or the horizontal and vertical sampling distances differ.

Place the calculation halfway between four inputs

Index the original samples at integer row and column coordinates, starting at zero. A block beginning at row r, column c spans rows r and r + 1 and columns c and c + 1. Both sample pairs are symmetric about the point (r + 0.5, c + 0.5) in row-column order. One convenient implementation stores the result under the block's starting index, but an overlay using geometric positions places it half a sample along both axes.

For a three by three array of samples, four complete internal blocks fit without adding any values at the border. Their centers sit at the four points whose row and column coordinates each come from {0.5, 1.5}. With a larger array the same counting gives one fewer complete block in each dimension than the input has samples. A library can return an array the same size as the input by choosing an extension rule and an anchor. Record both choices when exact alignment at the edges of an image matters.

Four crosses appear between a grid of nine integer-position sample locations.
The center of each two-by-two block lies halfway between its four pixel samples. Source: Zhilianhai editorial desk, original AI-assisted conceptual illustration.

One extra check isolates a bright sample in the center of an otherwise flat three by three patch. That single sample belongs to each of the four internal blocks, appearing once as each of the four possible corners. Subtraction therefore produces a response in four places. The signed response affected by the change depends on which corner the bright sample occupies. This exercise shows how an isolated intensity error can influence adjacent scores. Assessing whether those four scores trace a physical boundary takes additional image information.

Make comparisons reproducible on a small patch

Start a comparison with one constant block, one block with a horizontal brightness ramp and one block that changes on both axes. Retain the four input values, the two signed outputs and the resulting magnitude. A changed sign with an unchanged magnitude can then be traced to the difference orientation. A uniform factor between magnitudes can be traced to scaling. A displaced overlay can be checked against the geometric center and the output anchor. See more examples in the technical features and industry coverage.

Technical sources

Roberts' original thesis gives the diagonal differences in its chapter on picture input and reduction to lines, with an intensity transform ahead of the differences. The cited scikit-image release implements its own input conversion and combines the two kernels. Roberts’ original MIT thesis and scikit-image 0.23.2 source.

18028484626 CONTACT US

公司:智联海(惠州)科技有限公司

地址:惠州仲恺高新区陈江街道白云山工业大道 5 号六楼 601

Q Q:18028484626

Copyright © 2002-2026

粤xxx

咨询 在线留言 电话:18028484626
微信 微信扫码添加我