Bresenham's line algorithm 2026-10-31
Jack Bresenham's raster graphics algorithm selects a thin sequence of pixels to represent a line segment by exact incremental integer arithmetic. For a first-octant segment with , a scaled midpoint line decision chooses between the next same-row and next higher-row pixels.
Confocal optical sectioning 2026-10-14
At one depth, scan the illumination spot across and and assign the detector reading during each dwell interval to a pixel. Move the specimen or objective optical lens axially to acquire the next depth. A stack of these optical sections samples three-dimensional structure. With beam scanning, the returning fluorescence commonly retraces the scanning optics: this descanning holds the image of the currently illuminated point at the detection pinhole. With stage scanning, the fixed spot and pinhole remain aligned while the specimen moves. [ref]
An optical section is a depth-weighted image of an intact specimen, with a finite axial response and tails. A physical cut actually separates a slice of material; its thickness and cutting damage are properties of the preparation. Changing optical focus selects another optical section without removing a slice, although illumination can still damage a specimen. Neither a thin physical slice nor a sharply displayed optical section makes the imaging point spread function infinitely narrow. [ref]
Introductory Confocal Concepts by Nikon Instruments Inc.. Fig. 2 discussion: focused-light sections rather than physical sectioning
Point response and section thickness answer different questions. For a spatially uniform, very thin fluorescent sheet, its response versus axial displacement is proportional to the lateral integral of the three-dimensional confocal response,Consequently a trace through a single bead, , does not by itself give the sheet's optical-section thickness. State which object and which full width at half maximum are being measured. A smaller axial sampling step gives more samples of the same response, rather than automatically improving diffraction-limited resolution. [ref]
Confocal microscopy (chapter manuscript) by Brad Amos and others. Appendix §6, manuscript pp. 42–43: thin fluorescent sheet translated through focus
Data compression 2026-10-13
Data compression represents data using fewer bits than a specified original representation. The saving can reduce storage in a file system and reduce the number of bits sent through a communication channel. At a fixed transmission rate, fewer bits arrive sooner; this makes better use of a fixed transmission budget. Both the encoded data and the instructions needed to interpret them contribute to the size of a stored file.
There are two different promises. Lossless source coding preserves the original exactly: for an encoder and decoder , for every permitted input . Thus must be an injective function. Lossy compression allows to differ from , with the difference judged by an explicit criterion. A program or numerical record may require exact recovery; a preview image may tolerate altered pixels in return for fewer bits.
The appeal of lossless source coding is that repetition can be described rather than copied. Run-length encoding says "repeat this value twelve times"; a prefix code can give more frequent symbols shorter descriptions. These are distinct ways to exploit structure, and neither promises savings for every input. Image compression supplies especially visible examples of both lossless source coding and lossy compression.
Claude E. Shannon's 1948 paper made the role of probability distributions precise. For a memoryless classical information source with Shannon entropy bits per symbol, Shannon's source coding theorem bounds achievable average lengths; sufficiently long blocks allow exact codes to approach bits per symbol. This is a statement about a specified source and average lengths, not a promise to shorten every message.[ref]
Fano-limited X-ray CCD energy resolution 2026-10-20
A photon of energy fully absorbed in silicon produces on average electron-hole pairs, with variance rather than necessarily a Poisson variance. Thus and Gaussian FWHM is . Representative silicon values eV and give about eV FWHM at keV. read noise in split-event pixels, trapping and gain errors broaden that limit; optical pixel size alone does not specify the energy resolution.[ref]
The ASCA Data Reduction Guide by NASA HEASARC. §4.7, non-uniform CTI and Fano-limited FWHM expression
Fluorescence microscope 2026-10-14
A fluorescence microscope maps photon emission to an image. Excitation light passes through a fluorescence excitation filter and reflects from a wavelength-selective beam splitter into the objective optical lens. Returning fluorescence passes through that beam splitter and a fluorescence emission filter to the photodetector. Rejecting excitation makes faint emission visible.[ref]
Advanced Fluorescence Microscopy Techniques—FRAP, FLIP, FLAP, FRET and FLIM by Hellen C. Ishikawa-Ankerhold and others. §1.2.1, Figure 5 and excitation/emission-filter paragraphs
An ordinary image records emission-band counts at each pixel. Adding pulse-delay measurements gives a fluorescence lifetime map; scanning emission wavelength gives spectral information instead. Confocal microscopy adds spatial rejection and confocal optical sectioning, as developed in its own branch. An unlabeled specimen under the same illumination reveals intrinsic fluorescence and excitation leakage; excitation-blocked frames reveal detector background. A blank cannot perfectly predict background in a differently prepared specimen.
Grayscale 2026-10-13
A grayscale image varies along shades from black to white rather than recording independent colour differences. A numerical grayscale image assigns one shade sample to each pixel; an encoding determines how that sample maps to a displayed shade. A colour raster image can also look grayscale, for example when its three sRGB components are equal.
The convention in our lossy block averaging example is black at the integer code 0 and white at 255. Its arithmetic means act on those stored codes. This is a fully specified numerical experiment, but it does not claim that code 128 means half the physical light of code 255. PNG explicitly allows samples that are not proportional to light: its grayscale interpretation depends on the indicated transfer curve, and can be device-dependent when that information is absent.[ref]
https://www.w3.org/TR/png-3/#6Colour-values. W3C, PNG Specification, Third Edition, section 6.1: colour types, grayscale interpretation and transfer curves
Two different questions therefore need different operations. To average stored codes, average the integers. To average relative luminance for neutral sRGB shades, decode the codes to linear light, average there, and encode the result again. Equal weights on black and white give encoded value by the first method, but approximately by the second. Rounded to eight-bit codes these are 128 and 188. This example concerns ideal neutral shades and the specified sRGB conversion; it does not assert a universal grayscale conversion for every colour encoding.
The upper panels hold the spatial grid fixed and change sample depth: four levels produce broad constant bands, while 256 levels make smaller numerical steps. The lower panels hold the colour interpretation fixed and compare encoded sRGB values with relative luminance. All panels are calculated synthetic examples, not measured display data. Grayscale is useful when shade structure is the quantity of interest: a synthetic scalar image signal can be inspected without introducing separate colour components.
Image compression 2026-10-13
Image compression applies data compression to pictures, usually represented by raster images. Nearby pixels often have related shades; an encoder can exploit that structure. A flat region invites run-length encoding, while lossy block averaging trades fine detail for fewer stored samples. The choice depends on whether exact pixel values matter and on the patterns in the image.
Lossless source coding recovers the encoded pixel values exactly, including sharp text or numerical image data. Lossy compression preserves an approximation and can remove features that later image processing might need. A visually smooth result is therefore a different promise from exact recovery. Neither method has a universal compression ratio: the chosen file format, its file header and the particular image all matter.
PNG is a real format with lossless source coding of its encoded image data. Its specified compression uses Deflate on reversibly filtered rows, rather than our toy RLE format. The lossy block averaging example is also a teaching format, not a description of PNG. A lossy preprocessing step followed by saving as PNG preserves the already changed pixels, not the earlier original.[ref]
Portable Network Graphics (PNG) Specification (Third Edition) by Mark Adler and others. W3C, PNG Specification, Third Edition (2025), section 10, Compression
Lossy block averaging 2026-10-13
This toy image compression method stores one rounded arithmetic mean for each disjoint block of grayscale pixels. The quantization rule is round to the nearest integer, with exact halves rounded upward. Each stored value is an unsigned eight-bit integer. Reconstruction fills the original block with that value, a form of nearest-neighbor interpolation. Averaging already discards information; rounding can discard more.
Here is an exact source array. Index rows and columns by and defineThe floor function makes constant within each block; the indicator function adds 1 only to its upper-left pixel. All values are integers from 20 to 215. Each block therefore has the exact formFor example, the upper-left block has arithmetic mean and is stored as 40. The block immediately to its right is stored as 52. The complete stored array is specified by for . Its first row is ; its last is .
This toy file format again has eight-bit width and height fields followed by a one-bit mode: 0 means raw eight-bit grayscale pixels, 1 means the rounded block arithmetic means. This profile accepts only width and height 16. The decoder knows the block size and reconstruction rule from the format, reads the 64 stored values in row order, and repeats each across its corresponding block. The original 256 pixels cost payload bits; the 64 stored values cost payload bits. The reduction is . These payload counts exclude the common 17-bit file header; complete sizes are 2065 and 529 bits, or 2072 and 536 bits after final zero padding to eight-bit units. There is no stored codebook or additional prediction rule.
The empirical mean squared error averages squared differences over the 256 original pixel positions:Every block has the same four errors, so this value is exact in squared stored shade units. If the unrounded arithmetic mean could be reconstructed, the error would instead be ; eight-bit quantization adds . That hypothetical comparison does not count fractional means as free eight-bit values.
The broad shade pattern survives, while the alternating bright and dark pixels vanish. Indeed, a second source with every block constant at produces the identical stored array : exact decoding of both sources is impossible. This makes the storage benefit and the lost detail visible at once. Block averaging is useful for a coarse preview when the individual pixels are dispensable; choosing an acceptable mean squared error or visual result is part of the application, not a guarantee supplied by the encoder.
Lossy compression 2026-10-13
Lossy compression reduces a representation while permitting irreversible changes to the original. The encoder can map distinct inputs to the same output, so its decoder cannot recover both originals exactly. The useful question becomes how much storage is saved for an acceptable amount of distortion: mean squared error is one numerical criterion, but it does not by itself measure how noticeable a visual change is.
For example, storing the arithmetic mean of four grayscale pixels retains their average shade while discarding their arrangement. Blocks and both produce 50. The former has detail and the latter is uniform, yet the decoder receives the same value. Lossy block averaging makes this ambiguity, its bit saving and its mean squared error exact.
Microscope scale calibration 2026-10-14
Microscope scale calibration compares an image readout with a known specimen length. This documented practical uses an eyepiece graticule, stage micrometer and Köhler illumination. Focus the graticule; place the reference on the stage with the objective-appropriate cover glass. Focus both scales with the chosen microscope objective, then rotate and translate them into parallel alignment. Read widely separated coincidences using consistent line edges. Record the optical configuration and recalibrate for each objective.[ref]
Linear Measurements (Micrometry) by Thomas J. Fellers and Michael W. Davidson. Linear Measurements (Micrometry), Stage Micrometers and Eyepiece Reticle Calibration, Fig. 4 and procedure bullets
The stage micrometer is the reference; preserve the optical configuration when substituting the specimen. Line width, focus, edge selection and optical aberrations limit accuracy. Additional recommended checks are realignment and another known interval: agreement tests repeatability and scale consistency, not absolute reference accuracy.[ref]
Linear Measurements (Micrometry) by Thomas J. Fellers and Michael W. Davidson. Linear Measurements (Micrometry), Conclusions, line-edge choice and calibration errors; repeat-after-realignment check is an additional recommendation
Here is an original toy calculation, not the source's calibration example or measured data. Suppose a reference span coincides with eyepiece intervals. Then the calibration factor and the length corresponding to specimen intervals areThis works because both readouts use the same image-to-specimen scale: . One must count intervals, not tick marks; forty intervals have forty-one bounding ticks. In an ideal linear scale model, if identifying the calibration endpoints introduces a total readout error of interval, the inferred factor ranges from to per interval. Holding exact gives . This isolates one contribution to measurement uncertainty; it is not a complete uncertainty budget or a measured confidence interval.
For a recorded real image, image a stage micrometer at the same capture settings to calibrate length per detector pixel. Resizing changes length per pixel; update the scale bar accordingly. Eye-viewing angular magnification alone supplies no digital image scale.[ref]
Linear Measurements (Micrometry) by Thomas J. Fellers and Michael W. Davidson. Linear Measurements (Micrometry), Conclusions, digital images acquired at identical pixel resolution
Midpoint line decision 2026-10-31
For the implicit equation , the sign of compares the exact line with the midpoint between candidate pixel centres and . Multiplication by two makes the test integral. A consistent equality rule specifies which tied pixel is selected.
Nearest-neighbor interpolation 2026-10-13
Nearest-neighbor interpolation assigns each requested location the value of its nearest available sample, with a specified convention for ties. In lossy block averaging, samples are placed at block centres and each is copied into its four original pixel positions. This enlarges the raster image without recovering discarded detail.
Three advantages of integer arithmetic for raster graphics are:
- Cheap, fast operations. Historically, integer addition, subtraction and shifts needed much less hardware and execution time than floating-point arithmetic, especially on machines without a floating-point unit. An incremental Bresenham's line algorithm needs only a few additions and a decision per pixel.
- Exact decisions. Provided integer overflow is excluded, the scaled midpoint line decision is exact. There is no accumulated rounding error that can move a decision across a half-pixel boundary; equality has a reproducible tie rule.
- Simple storage and hardware. Integer coordinates already identify pixels. An implementation can keep coordinates and decision variables in ordinary registers and use a small add/compare datapath, avoiding conversion between floating-point numbers and integer screen addresses.
By exchanging axes, reversing endpoint order and reflecting coordinate signs where necessary, reduce a general line segment to the first octant:The vertical case is handled by exchanging axes. In this octant, increasing by one requires increasing by either zero or one. Thus, from the currently plotted pixel the candidates are and .
Use the implicit equation of the lineAt a fixed , means that lies below the exact line. The midpoint line decision evaluates , halfway between the two candidate pixel centres. If , the exact line lies below , so choose ; if , choose . At equality either candidate is equally near, but a fixed tie rule is essential. We choose on a tie throughout these solutions:This chooses the closest vertical-grid pixel centre in each column, with ties rounded upward. Since , the result has one pixel per column and consecutive pixels share an edge or a corner.
Multiply the midpoint line decision by two to remove the fraction. At the current pixel , maintainAt the initial endpoint this is . If is chosen, the next decision midpoint is displaced by and increases by . If is chosen, its displacement is and increases by . Both increments are constant, so the per-pixel work uses only integer arithmetic:The completed code, using the tie rule of part (b), is:
void midpointLine(int x0, int y0, int x1, int y1)
{
int dx, dy, incrE, incrNE, d, x, y;
x = x0; y = y0;
dx = x1 - x0;
dy = y1 - y0;
incrE = 2 * dy;
incrNE = 2 * (dy - dx);
d = 2 * dy - dx;
drawPoint(x, y);
while (x < x1) {
if (d < 0) {
d += incrE;
} else {
d += incrNE;
y++;
}
x++;
drawPoint(x, y);
}
return;
}Thus
guard1 is x < x1, and guard2 is d < 0. Multiplication by two is the only multiplication. Signed decision variables are convenient because and incrNE can be negative; this remains an integer arithmetic algorithm. A strictly unsigned hardware representation would need an equivalent biased or separated-sign encoding. As with the printed int skeleton, assume all intermediate values fit the chosen type; integer overflow would invalidate the mathematical decisions.To verify the geometry, write . The chosen ordinate isThe midpoint line decision selects exactly this nearest integer, rounding halves upward. Its increment between successive columns is zero or one. At and , it gives exactly and , respectively, so both endpoints are included and the line segment has precisely distinct pixels.
For the illustrated endpoints and , the ordinates are . In particular the exact ordinate at is , and the chosen pixel is .
The verifier can check the final geometric criterion directly, independently of the incremental decision variable. Set , , and define the scaled vertical residualThe exact line ordinate is , so . Nearest-integer selection with upward ties is preciselyThe strictness matters: at a half-integer ordinate the upper pixel has and passes, whereas the lower pixel has and fails. Each column has exactly one accepted integer ordinate.
With
reject() terminating verification unsuccessfully, suitable outline code is:void checkPoint(int x, int y)
{
Wide a = Wide(x) - x0;
if (a < 0) reject(); // inequality 1
Wide b = Wide(x1) - x;
if (b < 0) reject(); // inequality 2
Wide dx = Wide(x1) - x0;
Wide dy = Wide(y1) - y0;
Wide e = 2 * dy * a - 2 * dx * (Wide(y) - y0);
Wide lower = e + dx;
if (lower < 0) reject(); // inequality 3
Wide upper = dx - e;
if (upper <= 0) reject(); // inequality 4
counter[x]++;
}Wide denotes a signed integer type large enough for the products and differences, with conversion before subtraction. These are exactly four inequalities against zero, all applied to named integer variables. The arithmetic restriction on the drawing loop in part (c) does not restrict multiplication in this verifier. The screen endpoints are assumed valid, with and valid endpoint ordinates, so indexing is safe after the first two checks. These endpoint and screen preconditions belong in initialization if they are not guaranteed by the caller.No separate -range tests are needed: for between the endpoints, lies in , and its nearest integer lies in the same interval because both bounds are integers. The counters defer detection of omissions and repetitions to part (e). As for every finite counter, use adequate capacity or a sticky failure on overflow; saturating each counter at two also suffices because only zero, one, and “more than one” matter.
After every proposed pixel has passed part (d), insist on exactly one call in every column of the closed endpoint interval:
void final()
{
for (int x = x0; x <= x1; x++) {
if (counter[x] != 1) reject();
}
accept();
}Part (d) already rejected every out-of-range column and every incorrect ordinate. A zero counter now detects an omitted column; a counter greater than one detects a repeated call in that column. Because the residual interval in part (d) allows exactly one integer ordinate in each column, accepted calls in a repeated column must address the same pixel. Conversely, a counter of one in every column forces the complete set of nearest pixels, including both endpoints. Consecutive correct columns differ in ordinate by at most one, which proves that there are no gaps in the resulting thin line segment.
Interpret the given focal point as the centre of perspective projection, . First translate it to the origin with . The direction from to the world origin is then , of length 10. Choose the rotation matrix so that this direction becomes :Indeed, the transformed component is , and the transformed component is . Thus the required mapping, followed by the perspective divide, isFor a world point , its camera coordinates and projected device coordinates areThe world origin projects to and lies at camera depth 10. A point five units along the unit viewing direction from has camera coordinates , so it lies on the central image plane as expected. Here device coordinates are image-plane coordinates centred on the optical axis; an actual pixel viewport would require its own specified scale and offset.
Only rotations about the -axis are available. Consequently the camera's horizontal axis stays parallel to the world -axis; the viewing direction lies in the world plane. The available orientation has pitch but no independent yaw or roll. Translations move the camera and the projected origin but cannot supply the missing orientation degrees of freedom.
For single-shot ray tracing, construct one primary ray per pixel, normally through its centre on the image plane, with the camera centre as origin for perspective projection. Transform the ray into the scene's coordinates, or consistently transform all the scene geometry into camera coordinates.
Intersect that primary ray with the scene's triangles, using part (c), and retain the accepted hit with the smallest nonnegative parameter . This nearest-hit selection supplies visibility: farther surfaces cannot show through the first opaque surface. If there is no hit, write the background colour. At a hit , obtain its material colour and front unit normal vector and set toward the camera.
For each point light at , form , calculate the specular reflection direction, and evaluate its diffuse and specular contributions using the Phong reflection model. Sum the contributions and add ambient illumination once:The coloured surface can supply colour-dependent diffuse weights, and each source can have its own colour. Convert the result into the output image's colour encoding and range. Single-shot here means direct local shading after one primary visibility ray; no reflected or transmitted secondary viewing rays are followed. Part (e) adds secondary visibility queries for the lights.
Path tracing estimates the rendering equation by a Monte Carlo method. Launch camera rays; at each surface hit sample an outgoing continuation direction according to a chosen probability density function, trace to the next hit, and continue through successive reflections. Accumulate emitted light or environment light with the product of scattering, cosine and inverse-density factors along the path. A bounce sampled with density updates the path weight byAverage many independently sampled paths per pixel. Multiple bounces account for indirect illumination, including colour bleeding between surfaces, instead of approximating all of it by one ambient constant. Termination can use Russian roulette: continue with probability and divide surviving weights by , preserving the expected contribution. A fixed bounce cutoff is simpler but truncates transport.
The elementary strategy that obtains illumination only when a randomly continued path hits an emitter fails for ideal point lights. From a surface point, an ideal point source occupies zero solid angle; sampling a direction from an ordinary continuous probability density function hits that one direction with probability zero. Thus this strategy almost surely never discovers the light, regardless of the number of samples. An area emitter occupies nonzero solid angle and can be hit.
The qualification matters: practical path tracing can use point lights by explicitly sampling a source and connecting the current surface to it with a shadow ray, a technique called next-event estimation. For a point source the connection direction is known exactly, rather than discovered by a random hemisphere hit. Thus the restriction applies to naive emitter-hit path tracing, not to all path tracing algorithms.[ref]
Physically Based Rendering: From Theory to Implementation (4th edition) by Matt Pharr and others. §12.2: point lights have delta-position emission and deterministic incident directions; §13.4: direct-light sampling is combined with scattering-direction sampling



