A chain of resizes remembers its smallest picture
Worth reading first: A pixel is not a point · The pixel that is not square.
A thumbnail gives its camera a pixel it cannot see resized a crop once. A tool given a target width keeps the picture’s aspect by computing a height, which comes out fractional and is rounded, and that leaves the picture’s two focal lengths scaled by two different ratios of whole numbers. They disagree by at most one rounding of the target’s height, , the picture’s edge moves by at most half a target pixel, and no reading of a box and a square in the thumbnail is fine enough to see either.
The essay ended by pointing out that a picture on the web is rarely resized once. A crop becomes a figure at one width, the figure is scaled by a device’s ratio, and a preview card is cut from the page at a third width, each step taken by a tool that knows nothing about the others. A display’s scales cancel, if they are true maps had already followed a picture through several resamples, from a renderer’s buffer to a compositor to a screenshot, and found the roundings telescope: each undone by the next scale, so that only the last survives. The question was whether a chain of thumbnails does the same, or whether its roundings add; and whether a chain that enlarges between two reductions brings the crop’s own half pixel back at the largest scale it passed through.
A chain of resizes does not telescope. Each tool rounds the aspect it was handed, so every earlier rounding is kept, and the one that dominates is the rounding made in the smallest picture the chain passed through. The crop’s own half pixel, by contrast, comes back at the last scale and no other.
Three ways to reach 690 pixels
The crop is the earlier one: 211 by 131 logical pixels of a 1280 by 720 window composited at a device scale of 1.5, landing on 316 by 196 panel pixels when each edge is rounded. Its aspect asks for a picture 690 px wide to be 427.97 px tall.
Straight to 690, one tool rounds 427.97 to 428, and the picture’s two focal lengths agree to 0.006%. Through a 117 px thumbnail first, the first tool makes the thumbnail 73 px tall from an asked-for 72.57, and the second tool, handed a 117 by 73 picture, asks for and makes it 431. The final picture is 3 px taller than the crop’s aspect wants, a squeeze of 0.71%. Through a 25 px icon, the first tool rounds 15.51 to 16, the second asks for 441.6 and makes 442, and the final picture is 14 px too tall, a squeeze of 3.28%.
The reason is in what the second tool is told. It is handed a picture and keeps that picture’s aspect, and the picture’s aspect already carries the first rounding. Nothing in a 117 by 73 thumbnail says that it was meant to be 117 by 72.57, so the second tool keeps the error as faithfully as it keeps the scene. Written as a product, each step multiplies the picture’s aspect by , its own rounding relative to its own height, and the squeeze at the end is
where is the height the -th tool asked for before rounding. No later factor undoes an earlier one, because no later tool knows it is there.
The display’s chain was different in exactly one respect. Its scales were all of the whole frame and each was set from a stated size the next step knew, so the composition of true maps carried every pixel through to a final size that had been fixed in advance. Here the final size is not fixed in advance. It is computed, one tool at a time, from the previous tool’s answer. A rounded viewport has two focal lengths met the same arithmetic at the other end of the pipeline, where a renderer takes its aspect from a requested size and rounds the buffer, and there too the rounding was harmless only because one stated size was read once.
The bound is the sum, and the smallest picture’s share is largest
If every factor can be as large as its own rounding allows, the bound on the chain is the sum of the roundings, to first order. Whether a real chain comes near it is a separate question.
Sweeping the intermediate width through every whole pixel from 24 to 690, the final squeeze saws back and forth inside the sum of the two roundings and reaches 98% of it, so the sum is the chain’s real size and not a loose ceiling. The last step’s rounding alone allows ±0.117%, and through most small intermediate pictures the squeeze is far outside that: 0.71% through 117 px, 0.47% through 61, 2.11% through 30, 3.28% through 25. As the intermediate picture grows the envelope narrows towards the last step’s, and once the intermediate is as large as the final, the two roundings are equal partners and the squeeze can be about twice what one step leaves.
The sum is dominated by its largest term, and the largest term belongs to the smallest picture, since grows as shrinks. That is the sense in which a chain remembers its smallest picture. A thumbnail 73 px tall can contribute up to 0.69% on its own; a figure 431 px tall, 0.12%. A chain that passes through a thumbnail on the way to a large picture carries the thumbnail’s share whatever the large picture’s own rounding does.
The dashed line is a tool that does not take the aspect from its input. An image service that stores an original’s width and height, and computes every derived size from those, rounds once, at the size it produces, and the chain telescopes as the display’s did: 0.006% at 690 px whatever came before. The difference between the two tools is not their arithmetic, which is identical, but where they read the aspect from. A chain is safe exactly when every tool in it reads the same stated aspect and no tool reads another’s output.
This also answers the earlier essay’s question about enlargements. A chain that enlarges between two reductions, crop to 117 px, then up to 1,280, then down to a 300 px card, ends with a squeeze of 0.497% against the card’s own bound of 0.269%. The same card made from a 640 px figure enlarged to 960 ends at −0.041%. The enlargement in the middle contributes almost nothing either way; what separates them is the 117 px thumbnail, whose rounding the enlargement then carries forward.
Half a thumbnail pixel, at the scale of the last picture
A percentage of the focal length is one reading of the squeeze. What a person looking at the picture sees is where its edges are.
The final picture’s height is a whole number, so its error against the 427.97 px the aspect wants is a whole number of pixels plus 0.03. A single step can only make it 0.03 px, the rounding of the last tool. Through 117 px it is 3.03 px; through 25 px, 14.03 px, the worst over every intermediate width. The bound drawn is the half pixel each step’s rounding moves its own bottom edge, carried at the scale from that step’s picture to the end: half a final pixel for the last tool, plus half an intermediate pixel times for the one before. Half a pixel of a 25 px icon, scaled up 27.6 times, is 13.8 final pixels.
Every other row is moved in proportion to its height, so a point at the picture’s middle is wrong by half the edge’s error and a point at the top by none. That is a uniform vertical stretch of the scene, the shape the pixel that is not square drew for a camera with tall pixels, and for a reader of the picture it is the same thing: a circle drawn as an ellipse 3% taller than it is wide, a square drawn as an oblong.
The crop’s own rounding behaves differently, and the difference answers the second half of the earlier question. When the crop lands on the panel, each edge is rounded to a whole panel pixel, and a crop moves the frame and not the camera found that this moves the picture’s principal point by under half a panel pixel. Every resize after that is a true map, and true maps compose into one: . So the crop’s half pixel reaches the final picture at the product of the scales, which is the final width over the panel width, 690/316, whatever the chain did in between. An enlargement to 1,280 px in the middle of the chain does not bring it back at 1,280’s scale; it is undone by the reduction that follows, exactly. What an intermediate picture cannot undo is its own rounding, because that rounding is a change to the picture’s shape and not a change to its scale.
What can be read off the end of the chain
The single-resize essay found that a thumbnail’s squeeze is invisible: a recovery reading the pixel’s shape from a box and a square, the reading that a square closes the line of cameras built on the family of cameras a box leaves a line of cameras found, is always coarser than one rounding. A chain changes one of the two quantities. Its squeeze can be several percent at the end, in a final picture 690 px wide, where a box and a square are read to 0.24% if their lines are found to a tenth of a pixel. On those numbers the squeeze would stand out at ten times the reading’s spread.
But the final picture of a chain through a 25 px icon has been enlarged from 25 px, and an enlargement adds no detail. The lines of a box in it are as sharp as they were in the icon and no sharper: a line found to a tenth of an icon pixel is found to 2.8 final pixels. So the reading’s precision belongs to the smallest picture in the chain, just as the squeeze’s size does. The figure compares the two at the same width. At 64 px the largest squeeze is 1.26% and the box and square read it with a spread of 46% from half-pixel lines and 4.7% from tenth-pixel ones. At 690 px, 0.117% against 1.4% and 0.24%. The finer reading is never less than 2.0 times the squeeze it would need to see, at any width tried, and the smallest picture sets both.
That is the second way a chain remembers its smallest picture, and the two memories cancel for a reader. The squeeze a chain leaves is large in the final picture’s terms and small in the smallest picture’s, and the smallest picture’s terms are the ones in which it can be read. A recovery told that a chained picture’s pixels are square is wrong by the chain’s squeeze, which can be several percent, and still cannot find that out from the picture.
Roundings add as a root, floors in a straight line
A chain that passes through a tiny picture is an extreme case. A chain whose every picture is of a reasonable size still adds its roundings, and how fast it does so depends on whether they can cancel.
A rounding error of a whole height is spread evenly between plus and minus half a pixel, so its variance relative to the height is , and independent roundings add their variances. Over 3,000 chains at each length, the root-mean-square squeeze is 0.120% after one resize, 0.209% after three and 0.289% after six, against the predicted of 0.292% at six. The roundings are independent to the precision the measurement keeps, and the chain’s squeeze grows as the square root of the number of tools, a random walk whose steps are each tool’s rounding. Six reasonable tools leave a typical squeeze two and a half times one tool’s.
Every tool reading the source’s aspect instead leaves 0.120% after one resize and 0.118% after six. The last rounding alone survives, as it did on the display, and the length of the chain does not matter at all.
A tool that floors the height, which is what integer division does and what a surprising amount of image code does by default, never rounds up. Its error is between zero and one whole pixel short, half a pixel on average, so every step loses half a pixel of its own height on average and the losses cannot cancel. Floored, the mean squeeze is −0.176% after one resize, −0.541% after three and −1.078% after six, falling in a straight line, with a spread of 0.381% about it at six. Rounded, the mean after six is −0.006% and the spread 0.289%. After six floored tools the typical picture is a percent short, every pixel wider than tall, and the spread about that bias is smaller than the bias itself.
That is the case where pooling, which the single-resize essay offered as the one route by which a squeeze could show itself, actually would. A collection of pictures that went through the same flooring chain carries a common bias, and the bias does not average away however many are read. A rounding chain’s squeeze does average away, since it is as often one way as the other.
Chains the way the web makes them
The chains above draw their widths evenly. A real chain has a shape: a crop is placed as a figure several hundred pixels wide, a page scales it by the device’s ratio, and a card or a preview is cut at a smaller width. Each step is chosen by somebody who does not know about the others.
In this shape most chains stay inside the last step’s bound: 85.7% of the 4,000 do, and 14.3% exceed it, by up to 2.71 times. The reason is that the last picture is usually the smallest. A card 120 to 600 px wide is smaller than the figure it was cut from, so its own rounding is the chain’s largest term, and the figure’s adds a fraction of it. The chains that exceed it are the ones whose card is large and whose figure is small, or whose roundings happened to fall the same way.
The device ratio is the step nobody thinks about, and for integer ratios it does nothing at all: a picture 117 by 73 scaled by 2 is 234 by 146 exactly, with no height to round, and the measurement confirms that a ratio of 2 or 3 leaves every chain’s squeeze unchanged to the last digit. A ratio of 1.25 or 1.5 does round, when the height is not a multiple of four or two, but at the device’s size the height is large and the rounding small. The step to worry about is the one that makes the smallest picture, and on the web that is usually a thumbnail somebody asked for on purpose.
So the earlier essay’s single-resize bound is a fair working rule for most published pictures, and it fails in two recognisable cases: a chain that ends larger than one of its middle pictures, and a chain of tools that floor. Both are cases where the smallest picture was not the last.
Where the arithmetic came from
Every tool uses the true map, sending a pixel’s centre to a pixel’s centre, as halving a picture moves its centre found a tool must if it is not to shift the picture’s middle. A tool that multiplies coordinates instead adds its own shift at every step, and those shifts add as well; they move the principal point, which is a separate error from the squeeze measured here and is the one a careful reader of a tile is an off-centre frustum would expect a chain to accumulate too.
Heights are rounded or floored exactly, in whole-number arithmetic, so a height that falls on exactly half a pixel rounds up whatever a floating-point division would have made of it. A tool that rounds half to even differs only on those ties.
Each tool is given a width. A tool given a height instead rounds the width, and the same analysis applies with the roles of the two focal lengths exchanged; a chain that mixes the two kinds can have its roundings fall on both axes, and its squeeze is then the difference of two sums.
The reading compared is a box and a square, the recovery the earlier essays used. A calibration target read with many points reads the squeeze more finely, but it reads it in the picture’s information, and an enlarged picture holds the information of the smallest picture it came from.
Nothing here models the resampling filter. A real resize blurs as well as rounding, and a chain of resizes blurs repeatedly. The blur moves no edge’s centre, so it does not change the geometry measured here; it does make every line harder to find, which only strengthens the conclusion that the squeeze cannot be read.
Still open: whether a crop between two resizes walks the centre the way a rounding walks the shape
Every chain here resizes a whole picture. Real pipelines also crop in the middle: a figure is resized, a square card is cut from its centre, and the card is resized again. A crop is the step a crop moves the frame and not the camera measured, and it rounds the crop’s edges in the pixels of whichever picture it is taken from, which moves the principal point by up to half of that picture’s pixel. A resize carries the move at its scale, and the next crop adds its own.
The measurement that settles it interleaves crops and resizes, each crop centred on its picture and rounding its own corner, and asks whether the principal point’s error adds in the same way as the squeeze — as a sum, dominated by the crop taken from the smallest picture — or whether a centred crop’s rounding, which falls on both sides of the middle, cancels where a resize’s does not; and whether a chain that only ever takes centred crops from even-sized pictures, which a careful tool could guarantee, keeps the principal point exactly where the renderer put it.
A chain of resizes keeps every tool’s rounding, because each tool keeps the aspect of the picture it was handed and that aspect already carries the earlier roundings. The final squeeze is bounded by the sum of the steps’ roundings and fills it, so the smallest picture dominates, and an enlargement after a thumbnail brings the thumbnail’s half pixel back at the final scale. The crop’s own half pixel comes back only at the final scale, since true maps compose. Rounded steps add as a root of their number, floored steps in a straight line, and a tool that reads the source’s own aspect rounds once. The squeeze is read no better than the smallest picture allows, which is never fine enough to see it.
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 circle on the ground names the column and the focal length at once — both name focal length, identifiability
- A circle reads a tilted camera's column, and its tilt has to come from the verticals — both name focal length, identifiability
- A focal length is not an angle — both name aspect ratio, focal length
- A level picture shows its rise on its horizon, and hides its slide — both name focal length, identifiability
- A rectification's free shift is free only near the pair — both name bias, quantisation
- A scale chain leans rather than wanders — both name bias, random walk
Named objects
A flat tag is an object no other essay names yet.
Aspect ratioBiasFocal lengthIdentifiabilityQuantisationrandom walk