What a machine computes

A crop moves the frame and not the camera

A crop of a screenshot scales nothing. It moves the frame's corner and leaves the renderer's principal point where it was, so the cropped picture is exactly the picture of an off-centre camera and nothing in it can say otherwise. What the crop adds is the rounding of its edges to whole screen pixels, which moves the principal point by at most half a pixel each way, in a pattern that repeats with the crop's position and never grows. Converting the crop's corner with the map that is right for a pixel's centre adds half the scale's excess on top, a whole pixel on a display at 2 or 3.

Worth reading first: A pixel is not a point · A tile is an off-centre frustum.

A display’s scales cancel, if they are true maps followed a renderer’s camera from its buffer to a screenshot through every resample a display can put in the way. A compositor drawing a window at a whole-number scale and reducing it to the panel, and a screenshot read back at the window’s logical size, each round to whole pixels. Under the true map, which carries the centre of one pixel grid onto the centre of the next, the roundings telescope. Only the final size and the aspect the renderer assumed survive, the single-rounding bound holds through any chain, and a screenshot taken at the window’s own size shows the renderer’s square camera exactly.

Every one of those pipelines carried the whole frame. A screenshot is often not of the whole frame. It is of a window, or a region somebody dragged a rectangle round, and the rectangle is given in the logical coordinates the operating system speaks in. That essay ended by asking what a crop adds. A crop does not scale anything: it moves the frame’s corner and leaves the camera’s centre of projection where it was. On a display whose scale is not a whole number, though, a rectangle in logical pixels lands on fractional screen pixels and has to be rounded. How far does the rounded crop’s principal point land from where the renderer’s camera puts it? Is the error bounded like the roundings before it, or does it depend on where on the screen the crop was taken? And can a recovery that reads the principal point from a cropped screenshot tell a crop’s offset from a camera’s?

The three answers come in the opposite order to the questions. The third is the foundation: no recovery can tell, because a crop’s offset is a camera’s offset. The first two are then about the small error the rounding adds, which turns out to be bounded by half a pixel, cyclic in the crop’s position, and doubled by one plausible mistake in converting the rectangle.

A crop is an off-centre camera

The window is 1280 by 720 logical pixels on a display at a device scale of 1.5, drawn by a square camera whose principal point, the foot of the perpendicular from its centre of projection to the picture, is the middle of the window. The screenshot is taken through the composited pipeline of the earlier essay with true maps throughout and read at the panel’s size, so it carries the renderer’s camera with no error beyond the single rounding that essay bounded.

A crop moves the frame and leaves the camera's centre where it wasA 1280×720 window on a display at a device scale of 1.5, drawn by a square camera whose principal point is the window's centre (dot), and three crops of a screenshot of it, asked for in logical pixels. In each crop the principal point stays where the camera put it, so a crop away from the middle is the picture of an off-centre camera: the crop at the lower right has its principal point 512.5 px to the left of its own left edge and 165.5 px above its top, in its own pixels. Rounding the crop's edges to whole pixels moves that point by 0.50 px across and 0.00 px down, the whole of the error a crop adds. The slider moves the third crop sideways.the camera's principal point1280×720 logical, device scale 1.5crop rounding: 0.50, 0.00 px
Fig. 1 The window, the camera’s principal point at its middle, and three crops of a screenshot of it. Each crop’s own middle is joined to the principal point it inherits. The slider moves the third crop sideways a logical pixel at a time.

Cut a rectangle out of that screenshot and every pixel inside it keeps its value. A scene point that was at screen pixel (u,v)(u, v) is at (u−ℓ,v−t)(u - \ell, v - t) in the crop, with ℓ\ell and tt the crop’s left and top edges in screen pixels. The camera that would draw the cropped picture directly has the same focal length as the renderer’s and a principal point at (cx−ℓ, cy−t)(c_x - \ell,\, c_y - t). The crop in the lower right of the figure has its principal point 510.5 px to the left of its own left edge and 165.5 px above its top. Checked over a grid of directions, the cropped picture and that off-centre camera’s picture agree to 10−1310^{-13} px, which is the arithmetic’s rounding and nothing else.

That is the off-centre frustum a tile is an off-centre frustum built on purpose: a renderer drawing one picture in tiles draws each tile with the whole frustum’s sides read at the tile’s own bounds, which is exactly a camera whose principal point lies outside its frame. A crop produces the same object after the fact, and the centre of the picture is not the centre of the paper made the same point about a printed photograph cropped by an enlarger.

It answers the last of the three questions outright. A recovery that reads the principal point from the cropped picture alone, from its vanishing points as recovering the camera does or from a box as a box leaves a line of cameras does, recovers (cx−ℓ, cy−t)(c_x - \ell,\, c_y - t). There is no second quantity in the picture for it to recover. A camera whose lens was shifted, a tile of a larger render and a crop of a centred screenshot are the same picture. The only way to tell them apart is to know the rectangle, and then the renderer’s principal point is the recovered one plus the crop’s corner.

The crop changes one more thing a reader might not expect, and it is not the focal length. A crop keeps the renderer’s focal length in screen pixels, 935 px for this window, which drew 1,920 screen pixels across a horizontal field of 91.5°. A 300-pixel crop of it, read as a picture in its own right, has a field of 2arctan⁡(150/935)2\arctan(150/935), 18.2° across if its principal point were at its middle. So a recovery handed the crop finds a long lens, aimed to one side: a narrow field and a principal point that may lie outside the frame altogether. Both readings are correct. The crop is a picture made by that lens, and the renderer’s wide camera is a camera that, cut down, makes it.

The rounding is under half a pixel and cycles

So the question that remains is the one the essay title promises a number for: when the crop’s corner is known only in logical pixels, how far off is the corner the screenshot tool actually used?

A crop’s left edge at logical pixel xx is a position, not a pixel. On a display at scale dd it lies at d xd\,x screen pixels, exactly, and a whole-pixel crop has to put it at a whole number. The natural way is to round it. The renderer’s principal point then lands d x−round(d x)d\,x - \text{round}(d\,x) screen pixels from where the request meant it, horizontally, and the same with the top edge vertically. Nothing else about the crop enters: not its size, not where on the screen it is, except through the fraction of d xd\,x.

A crop's rounding moves the principal point by under half a pixel, in a pattern that repeatsHow far rounding a crop's left edge to whole screen pixels moves the camera's principal point in the cropped picture, against where the edge was asked for, for crops starting at logical pixels 400 to 416. At a device scale of 1.25 the edge lands on 1.25 x screen pixels, whose fraction cycles 0, 0.25, 0.5, 0.75 every four logical pixels, so the error cycles 0, +0.25, −0.5, −0.25 px. At 1.5 it alternates 0 and −0.5; at 1.75 it runs through the same four values in the other order. It is never more than half a pixel and depends on the crop's position only through that fraction, not on where on the screen the crop is or how large.-0.50000.500400405410415the crop's left edge (logical px)principal point moved (screen px)device scale 1.25device scale 1.5device scale 1.75each edge rounded to the nearest pixelnever past half a pixel
Fig. 2 How far rounding the crop’s left edge moves the principal point in the cropped picture, against where the edge was asked for, from logical pixel 400 to 416, at device scales of 1.25, 1.5 and 1.75.

At a scale of 1.25 the fraction of 1.25 x1.25\,x runs 0, 0.25, 0.5, 0.75 and starts again every four logical pixels, so the principal point moves 0, +0.25, −0.5 and −0.25 px, and repeats. At 1.5 it alternates between 0 and −0.5. At 1.75 it runs through the same four values as at 1.25 in a different order. At whole-number scales the edge is always on a pixel and the crop is exact.

So the answer to whether the error depends on where the crop was taken is yes and no. It depends on the crop’s position, but only through a fraction that cycles every few logical pixels, so a crop at the top left and one at the bottom right with edges in the same phase have the same error. It never exceeds half a pixel in each direction, 0.707 px together, at any scale or any position. That is the size of a single rounding, the same bound the earlier essays found for the buffer, and it does not accumulate with them: the screenshot’s own rounding and the crop’s are of different things, one the camera’s focal lengths and the other its principal point.

Four ways to convert a rectangle

The rounding above assumes the tool converts the rectangle the way a position should be converted: multiply by the scale and round each edge. Not every tool does, and three other conversions are plausible enough to be written.

One rounds the origin and the size separately. The left and top edges come out the same, so the principal point is moved identically; only the right and bottom edges can disagree with the edge rounding by a pixel, which matters later. Another treats the crop’s corner as a pixel rather than an edge and carries it by the true map between pixel grids, d(x+12)−12d(x + \tfrac12) - \tfrac12, then rounds. That map is right for a pixel’s centre, which is why the earlier essays insisted on it, and wrong for an edge, which sits half a pixel from any centre. The third takes the smallest box of whole pixels that contains the rectangle, flooring the left edge and taking the ceiling of the right.

Reading a crop's edge as a pixel adds half the scale's excess to every cropThe largest distance, over every 200×150 crop of a 1280×720 window, between where the renderer's camera puts its principal point in the cropped picture and where the rounded crop puts it, in screen pixels, for four ways of converting the logical rectangle at device scales of 1.25, 1.75 and 2.5. Rounding each edge, or the origin and the size separately, leaves at most half a pixel in each direction, 0.707 px together, at every scale. Carrying the origin by the map that is right for a pixel's centre adds (d − 1)/2 before the rounding, and reaches 1.41 px at 2.5. The enclosing box floors the origin and reaches 1.06 px.each edge rounded, at 1.250.707 pxorigin and size rounded, at 1.250.707 pxedge read as a pixel, at 1.250.707 pxenclosing box, at 1.251.061 pxeach edge rounded, at 1.750.707 pxorigin and size rounded, at 1.750.707 pxedge read as a pixel, at 1.751.061 pxenclosing box, at 1.751.061 pxeach edge rounded, at 2.50.707 pxorigin and size rounded, at 2.50.707 pxedge read as a pixel, at 2.51.414 pxenclosing box, at 2.50.707 pxworst over every crop, 200×150pale: past half a pixel each way
Fig. 3 The largest distance, over every 200×150 crop of the window, between where the renderer’s camera puts its principal point in the cropped picture and where the crop as rounded puts it, for the four conversions at device scales of 1.25, 1.75 and 2.5.

Rounding each edge and rounding origin and size leave the same worst case, 0.707 px, at every scale. The enclosing box reaches 1.06 px at 1.25 and 1.75. Reading the edge as a pixel’s centre reaches 1.06 px at 1.75 and 1.41 px at 2.5, twice the single rounding.

The last is the instructive one, because it is the earlier essay’s lesson applied to the wrong object. Halving a picture moves its centre found that a resample must carry centres to centres, and that the naive map, which carries corners to corners, leaves the picture’s centre a quarter of a pixel off. A crop is the reverse case. What it carries is an edge, and the corner-to-corner map, multiplication by the scale, is the right one for an edge. The centre-to-centre map adds (d−1)/2(d - 1)/2 to every edge before the rounding: a quarter of a pixel at 1.5, three quarters at 2.5, a whole pixel at 3.

Means that are not zero

A worst case is what can happen to one crop. A bias is what happens to all of them, and a bias in the principal point is the kind of error a recovery averaging over many screenshots does not average away.

Rounding halves up leaves a small bias, and reading an edge as a pixel leaves half the scale's excessThe principal point's mean horizontal movement over every crop position, against the device scale, for three conversions. Rounding each edge to the nearest pixel, with halves rounded up, leaves a small bias wherever an edge can land exactly on a half: -0.250 px at 1.5 and -0.125 px at 1.25, nothing at whole-number scales. Reading the edge as a pixel's centre moves it by (d − 1)/2 before the rounding: -0.625 px at 2.25, and a whole pixel at 2 and at 3, where every other conversion is exact. The enclosing box rounds the edge down, a bias of 0.375 px the other way at 1.75.-1-0.50000.5001.5022.503device scalemean principal point moved (screen px)each edge roundededge read as a pixelenclosing boxmean over every crop positionedge as pixel: −(d − 1)/2
Fig. 4 The principal point’s mean horizontal movement over every crop position, against the device scale, for each-edge rounding with halves rounded up, for the edge read as a pixel’s centre, and for the enclosing box.

Rounding each edge to the nearest pixel would be unbiased if no edge ever landed exactly on a half. At scales like 1.5 and 1.25 a quarter or a half of the edges do, and rounding halves up moves every one of them the same way: the mean is −0.25 px at 1.5 and −0.125 px at 1.25 and 1.75, the principal point shifted left and up. Rounding halves to the nearest even pixel would remove it. The enclosing box floors every edge, so its mean is a bias of the same size the other way, +0.375 px at 1.25 and 1.75. Reading the edge as a pixel’s centre adds (d−1)/2(d - 1)/2 to every crop, so its mean falls with the scale: −0.625 px at 2.25, and a whole pixel at 2 and at 3, scales at which every other conversion is exact.

The last number is the one worth carrying. A tool that converts crops with the centre map is exact for no crop at any whole-number scale above one, and on the most common high-density displays, at a scale of 2, it moves every cropped screenshot’s principal point by a whole pixel up and to the left.

A crop saved at its logical size

Screenshot tools often save a crop at its logical size, so that a 200×150 rectangle becomes a 200×150 picture. That is a resample, and on a fractional display it is one whose scale depends on the crop’s rounded size: a crop whose right edge rounded differently from its left is a screen pixel wider or narrower than its logical width times the scale, and the resample stretches it to fit.

A crop saved at its logical size stays within a pixel, and closest when each edge is roundedThe crop read back at its own logical size, 200×150, by the true map: the largest distance over every crop position, at the crop's corners, between where this picture puts a direction and where the renderer's camera, shifted by the crop's origin, puts it. Rounding each edge leaves 0.57 px at 1.25 and 0.28 at 2.5, nothing at 2. Rounding the size separately can make the crop a screen pixel too wide or narrow, and the readback stretches it: 0.89 px at 1.25. Reading the edge as a pixel's centre reaches 0.57 px at 2.5.00.2500.5000.75011.251.501.7522.252.50device scaleworst displacement at a corner (logical px)each edge roundedorigin and size roundededge read as a pixelenclosing box200×150 crops, saved at logical sizeedges: under 0.57 px
Fig. 5 The crop read back at its own logical size, 200×150, by the true map: the largest distance over every crop position, at the crop’s corners, between where the saved picture puts a direction and where the renderer’s camera, shifted by the crop’s corner, puts it, against the device scale, for the four conversions.

Each-edge rounding stays under 0.57 px at the corners at 1.25 and under 0.48 px at 1.5, and is exact at 2. Rounding the size separately is now worse, 0.89 px at 1.25, because a size rounded on its own can disagree with the edges and stretch the whole crop. The enclosing box is wider than the rectangle by up to a screen pixel each side and is stretched back by the readback. Reading the edge as a pixel’s centre, which moved every edge, reaches 0.83 px at 1.75. Everything stays under a logical pixel, so the crop saved at its logical size is a usable picture of the renderer’s camera, shifted, with an error the size of the single rounding the window’s own screenshot already had.

What a cropped screenshot carries

Put together, the measurements say what a cropped screenshot is. It is the picture of the renderer’s camera with its principal point moved by the crop’s corner, exactly, plus a rounding of that corner of under half a pixel each way. A recovery reading the principal point from the picture finds the moved point and cannot find anything else, because there is nothing else there. A recovery that knows the rectangle in logical pixels can put the renderer’s point back to within the rounding: 0.707 px at worst, 0.4 px on average, with a bias of a quarter of a pixel if the tool rounded halves up.

That is a small error against what recoveries usually achieve. A principal point read from vanishing points is uncertain by many pixels, which is why most recoveries assume it is at the middle of the frame rather than reading it. For a crop that assumption is not a small error but the whole of the crop’s offset, 510 px in the figure’s third crop. The rounding question has a sub-pixel answer, and the question of what to assume has an answer hundreds of times larger: a crop is the one operation on a screenshot after which the middle of the frame is certainly not the principal point.

The quarter-pixel shifts this chain of essays has kept finding share a form: each comes from treating a position and a pixel as the same kind of thing. A pixel is not a point made the distinction for a renderer’s sample positions. A crop’s edges are positions, a resample’s samples are pixels, and each has its own correct map. Using either map for the other leaves half the scale’s excess in the picture.

The window, the crops and the tool, as assumed

The screenshot is taken by true maps throughout and read at the panel’s size. The earlier essay found that this pipeline carries the camera with the single rounding’s anisotropy and nothing else, so the crop’s error here is measured against the renderer’s own camera, not against an earlier error. A screenshot taken through a naive compositor starts with its centre already moved, and a crop adds its rounding to that.

Crops are 200×150 logical pixels, at every position on a 1280×720 window. The principal point’s error depends only on the left and top edges, so the size matters only for the readback at logical size, where a larger crop dilutes the one-pixel disagreement in its width and a smaller one concentrates it.

Rounding is to the nearest pixel with halves rounded up, as most programming languages’ default rounding does. Rounding halves to even would remove the mean of the each-edge conversion at 1.5 and 1.25, and leave its worst case unchanged.

The renderer’s camera is square and centred. A renderer drawing with an off-centre frustum, as a tiled renderer or a lens-shifted camera does, starts with a principal point away from the middle; a crop moves it by the same corner and adds the same rounding.

Still open: whether a scaled crop keeps the camera’s focal length

Every crop here keeps the renderer’s focal length in screen pixels and, saved at logical size, rescales it by the crop’s own rounding. A crop is often then resized to fit somewhere else: a thumbnail, a figure in a document, a picture uploaded at a fixed width. That is a resample with a scale chosen to fit a target size, not to undo the device scale, and it multiplies the focal length by a ratio of two whole numbers that need not agree horizontally and vertically.

The measurement that settles what it costs carries each crop through a resize to a stated target width with the height chosen to keep the aspect, rounded, and asks how far the resized picture’s two focal lengths differ; whether the difference is bounded by one rounding in the target’s pixels, as every true-map step so far has been, or can grow when the target is small; and whether a recovery reading the focal length from a thumbnail, at a few hundred pixels across, can tell the resize’s anisotropy from a camera whose pixels were not square, which the pixel that is not square found is a difference a recovery has to be told rather than shown.

A thumbnail gives its camera a pixel it cannot see takes that measurement: the two focal lengths disagree by one rounding of the target’s height, half a pixel times the crop’s focal length in heights in pixels, the picture’s edge moves under half a pixel, and a box and a square in the thumbnail read the squeeze far too coarsely to see it.

A crop moves the frame’s corner and leaves the camera’s centre, so a cropped picture is an off-centre camera’s picture and nothing in it can say which. What the crop adds is the rounding of its corner to whole screen pixels: under half a pixel each way, cycling with the corner’s position, a quarter-pixel bias if halves round up. Carrying the corner as though it were a pixel’s centre adds half the scale’s excess, a whole pixel at a scale of 2.

What links here

Computed from the collection, not written here: the essays that point at this one.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A flat tag is an object no other essay names yet.

field of viewFocal lengthPrincipal pointQuantisationSampling grid