A crop moves the frame and not the camera
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.
Cut a rectangle out of that screenshot and every pixel inside it keeps its value. A scene point that was at screen pixel is at in the crop, with and 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 . 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 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 . 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 , 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 is a position, not a pixel. On a display at scale it lies at 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 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 .
At a scale of 1.25 the fraction of 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, , 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.
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 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 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 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.
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.
- A rounded viewport has two focal lengths — both name focal length, principal point, quantisation, sampling grid
- A climbing dolly zoom stands its still points upright — both name field of view, focal length, principal point
- A dolly zoom is a step and a zoom, and they meet at one depth — both name field of view, focal length, principal point
- A dolly zoom off the axis keeps a line, not a plane — both name field of view, focal length, principal point
- Both vanishing points on the paper — both name field of view, focal length, principal point
- Focusing is a zoom — both name field of view, focal length, principal point
Named objects
A flat tag is an object no other essay names yet.
field of viewFocal lengthPrincipal pointQuantisationSampling grid