Undistorting an image often creates a choice: fill the output rectangle with valid content, or retain more of the original view and accept empty borders. The undistortion scaling parameter controls that choice; it does not improve the underlying calibration. For inspection software, the practical issue is keeping the output camera matrix, crop coordinates and validity region consistent. You can change the displayed view without recalibrating, provided the original camera geometry remains unchanged.
Choose coverage before choosing a crop
For the conventional pinhole routine getOptimalNewCameraMatrix, the scaling parameter is commonly called alpha, with values between 0 and 1. It selects a new virtual camera view for the requested output dimensions.
| Setting | Intended result | Main trade-off |
|---|---|---|
| Alpha = 0 | Fill the output with valid image content | Some original peripheral content is excluded |
| Alpha = 0.5 | Intermediate coverage | Neither border removal nor retained coverage is maximized |
| Alpha = 1 | Retain the original captured field | Invalid regions can appear around the image |
These are geometric objectives, not guarantees about every interpolated border pixel. Check the actual remapping result before accepting a measurement region.
Alpha is not a percentage of retained field of view. A setting of 0.5 does not mean half the scene remains. Different distortion models and output dimensions produce different results.
What changes, and what stays calibrated
Calibration supplies an original camera matrix, usually written as K, and distortion coefficients, written as D. The routine uses these inputs to calculate a new camera matrix, K_new, and a valid-pixel rectangle.
It does not refit the calibration observations or estimate better distortion coefficients. Changing alpha changes the output projection, not the physical lens.
Here, fx_new and fy_new are focal lengths expressed in pixels. The principal point is (cx_new, cy_new). These equations apply to undistorted output coordinates, assuming zero skew.
The remapping operation finds a source location for each output pixel. Locations outside the source image cannot supply real scene information, so the border policy fills them instead.
Undistortion should straighten imaged straight lines when the calibration model fits. It does not make every pair of parallel scene lines parallel in the image; perspective convergence remains.
Crop the image and update its coordinates together
The returned validity rectangle describes a crop within the undistorted output, not within the raw image. Its origin is usually expressed as (x0, y0), followed by width and height.
Cropping changes the pixel-coordinate origin. Subtract the crop offset from both image points and the principal point. The focal lengths remain unchanged if the crop is not resized.
For example, suppose an undistorted image is 1280 × 960 pixels. Its focal lengths are both 1000 pixels, and its principal point is (640, 480).
Crop from (80, 50) with dimensions 1120 × 860 pixels. The cropped principal point becomes (560, 430). A point originally at (750, 500) moves to (670, 450).
The horizontal normalized coordinate remains identical:
Using the cropped image with the uncropped matrix would produce the wrong ray. For a related treatment of coordinate conventions, read intrinsic conversion between depth and texture images.
Treat the validity rectangle as a starting point
Black pixels are not a reliable validity mask: the inspected part may also contain genuinely black areas. A rectangular crop also cannot describe every possible irregular valid region.
For stricter validation, generate a mask from the same source-coordinate maps used for the image. Mark a destination pixel valid only when its required source samples lie inside the usable source region.
Interpolation matters. A sample center inside the source boundary can still require neighboring samples outside it. Your mask should follow the interpolation method, rather than checking only the center coordinate.
For multiple cameras or changing output settings, calculate validity separately for each configuration. Do not reuse a rectangle merely because the output dimensions match.
Select alpha with a repeatable image test
Start with the inspection requirement, not the most attractive preview. A presence check near the center and a measurement near the image corner may need different output views.
- Capture a fixed reference image with features near the center and perimeter.
- Generate outputs at alpha values of 0, 0.5 and 1, keeping output dimensions constant.
- Display each validity mask and mark the required inspection region.
- Choose a setting that retains that region with adequate border clearance.
- Verify measurements using the matching output matrix and crop transform.
Check straightness and measurement error independently. A visually convincing image can still contain residual calibration errors; checking barrel distortion correction accuracy explains that distinction.
Alpha is not the right remedy when the required feature was never captured. Revisit framing using calibration target coverage margins. Likewise, enlarging the output does not create additional captured detail.
For dimensions in physical units, retain the appropriate plane calibration or pose relationship. The marker-based length measurement guide covers that additional requirement.
Keep hardware and processing settings traceable
Changing only alpha normally does not require new calibration images. Changing focus, zoom, optical mounting, or the camera's source geometry may invalidate the calibration or require a documented coordinate transformation.
When selecting area scan cameras, compare acquisition requirements in the camera finder. The LS-CMR-0053 is a camera candidate to evaluate against those requirements.
- Sensor format
- 1/1.7"
- Interface
- GigE
- Resolution
- 12 MP
- Shutter
- Rolling
For machine vision lenses, use the lens finder to check coverage, mounting and sampling suitability. The LS-FFL-0567 is a lens candidate, not a guarantee of calibration accuracy or a validated pairing.
- Type
- Machine vision fixed
- Sensor format
- 1.1"
- Mount
- C-mount
- Resolution
- 16-25 MP
Before releasing the inspection, record this short checklist:
- Original calibration matrix, distortion model and coefficients.
- Source dimensions and any acquisition crop or binning.
- Alpha, output dimensions and new camera matrix.
- Validity-mask method and interpolation setting.
- Crop origin, cropped matrix and any subsequent resizing.
- Measurement results across the accepted inspection region.
If you resize after cropping, apply the resize operation's coordinate convention to the matrix and points as well. For hardware selection, start with the camera configurator; for help reviewing the geometry, send the settings and inspection requirements through technical support.
Questions
Does changing the undistortion scaling parameter improve calibration?
No. The parameter selects a different undistorted output projection using the existing calibration. It changes the new camera matrix and the balance between retained coverage and invalid borders. Calibration quality still depends on the original observations, distortion model and stability of the optical setup.
Should an inspection use alpha = 0 or alpha = 1?
Use alpha = 0 when filling the output with valid content matters more than retaining peripheral scene information. Use alpha = 1 when preserving the captured field matters more, then mask invalid borders. Compare intermediate settings against the actual inspection region rather than choosing from appearance alone.
Why must the camera matrix change after cropping?
Cropping moves the image origin, so pixel coordinates no longer refer to the same principal point location. Subtract the crop origin from the principal point and from measured image coordinates. Without resizing, the focal lengths in pixels stay unchanged.
Can detection software simply ignore the black borders?
Only after invalid regions have been excluded reliably. Dark border fill can merge with real shadows or part features and create false detections. Build a validity mask from the remapping geometry, account for interpolation, and restrict detection and measurement to accepted pixels.

