AI Glossary / Computer vision and multimodal AI / Intermediate
Merit function
Definition
A merit function is a numerical objective used to score candidate solutions during optimization. In lens design, it commonly combines weighted deviations from optical targets and penalties for undesirable design properties. The optimizer changes design parameters to improve that score, usually by minimizing it under the chosen convention.
What it means
A lens must satisfy several requirements at once: image sharpness across the field, acceptable distortion, focal length, physical size, and other constraints. A merit function translates selected requirements into a single quantity that an optimization algorithm can compare.
The score is designed, not discovered as a universal measure of lens quality. Its terms, targets, weights, and scaling express priorities. A candidate that wins under one merit function may lose under another because the intended application values different compromises.
The term also appears beyond optics, including constrained numerical optimization. This entry emphasizes the lens-optimization meaning associated with computational photography while retaining the broader idea of a purpose-built scalar objective.
How it works
Choose adjustable parameters such as surface curvatures, spacings, or other permitted design variables. Use a forward model, often ray tracing, to predict the optical system's behavior at selected field positions, wavelengths, and configurations.
Calculate residuals between predicted values and targets. A common form sums weighted squared residuals, sometimes with normalization or a final square root. Include suitable penalties or separately enforced constraints for requirements that performance terms alone do not capture.
The optimizer proposes parameter changes and reevaluates the score. Designers inspect both the total and individual contributions, because an improvement in one term can hide deterioration in another. Local optimization can settle in one basin of the design space; a low score does not establish that the globally best feasible design has been found.
Three practical examples
1. Compact-camera optics: A design team balances image quality against a limited physical envelope. It includes both optical errors and relevant size requirements rather than optimizing center sharpness alone.
2. Inspection-camera design: Engineers emphasize the field positions and wavelengths used by the actual measurement setup. They check distortion and off-axis behavior that would affect dimensional analysis.
3. Optics-and-software research: A team evaluates a candidate optical system together with a reconstruction algorithm. Its objective may include final image quality, while separate tests examine whether the combined system remains reliable under changed conditions.
Think of it this way
Think of a scored design brief in which several requirements contribute to the total. A candidate can earn a better overall result while becoming worse on one individual requirement if the improvement elsewhere outweighs it.
The analogy has limits: an optimizer follows the mathematical scoring rules, not the designer's unstated intent. Important requirements omitted from the score and constraints may receive no protection at all.
Worked example
Consider a simplified merit function M = ec² + 2ee² + 4p². The quantities are dimensionless normalized residuals: center-image error ec, edge-image error ee, and a size-violation penalty p. Lower is better.
Candidate A has residuals (1, 3, 0), so M = 1 + 2 × 9 = 19. Candidate B has (2, 2, 0.5), so M = 4 + 2 × 4 + 4 × 0.25 = 13. This score prefers B, although its center error and size penalty are worse.
If the weight on size violation rises from four to forty, B's score becomes 4 + 8 + 10 = 22, while A remains nineteen. The preferred design changes because the priorities changed.
This is an invented scoring example, not a prescription for an optical design program. If the size limit is an absolute requirement, a soft penalty may be insufficient: B might need to be excluded as infeasible regardless of its other improvements.
Illustrative case study
Fictional case: A startup optimizes a lens for a document-scanning device. Its initial merit function gives most weight to the image center, and the resulting design looks impressive in a central test crop. Text near the corners remains less clear.
The team updates the field sampling and requirements to reflect full-page use, then compares the new design's individual optical measures and simulated document images. It also evaluates plausible manufacturing variations rather than accepting only nominal performance.
The scenario illustrates objective design. It does not claim a measured improvement or suggest that changing weights can eliminate every physical tradeoff.
Common misconceptions and mistakes
Do not compare raw merit values across different definitions as though they share one scale. Changing normalization, weights, terms, or sampling can change the number without a corresponding universal quality change.
Do not assume a large positive penalty guarantees a hard constraint. The optimizer may accept a violation if the total score improves enough elsewhere, depending on the formulation.
Avoid treating a lower nominal score as proof of manufacturability, robustness, or final application performance. Also check units: combining unnormalized millimeters, degrees, and image errors can create accidental priorities driven by numerical scale rather than design intent.
Business use
A well-designed merit function makes engineering priorities explicit and supports systematic comparison of candidate systems. It is also a communication tool: teams can see which requirements drive the solution and which compromises are being accepted.
Maintain the objective definition alongside results, including targets, weighting, field and wavelength sampling, and constraint handling. Review component scores and independent performance plots. Before adopting a design, test conditions that were not overrepresented during optimization and assess sensitivity to tolerances. The score guides search; the complete evidence supports the final engineering decision.
People also ask
Is a higher merit value always better?
No. In many lens-design formulations the optimizer minimizes an error-like merit function; always check the convention.
Can the same design receive different merit values?
Yes. Different objectives, targets, weights, and normalization produce different scores.
Does the optimizer choose the correct business priorities?
No. The team must encode relevant priorities and constraints and validate whether the result serves the intended use.
Check your understanding
A design's total merit improves while corner-image error increases. Is that impossible?
Answer: No. Other weighted terms may improve enough to outweigh that deterioration. Inspect the individual contributions.
Related terms
- Objective function
- Loss function
- Weighted least squares
- optical optimization
- ray tracing
- constraint
- local minimum
- tolerancing
Learn next
Construct a small weighted objective and vary one priority to see how candidate rankings change. Then distinguish soft penalties from hard feasibility requirements and examine why aggregate scores need component-level review.
More in Computer vision and multimodal AI
- Median filter - A median filter replaces each value with the median of values in a nearby window.
- Median-threshold bitmap (MTB) - A median-threshold bitmap (MTB) is a binary image that marks whether each pixel is brighter than the image's median intensity.
- Membrane - In Poisson image editing, a membrane is a smooth correction surface that carries the difference between source and destination boundary values into the...
- Mesh subdivision - Mesh subdivision divides a polygon mesh into smaller faces.
- Mesh / triangulation warp - A mesh or triangulation warp deforms an image using a network of control points connected into triangles.
- Metamerism - Metamerism is the property whereby different spectral distributions produce the same tristimulus color values in a specified colorimetric system.
Sources
Frédo Durand, Lens Optimization: https://people.csail.mit.edu/fredo/comp-photo-book/09-optics-lenses-and-aberration-correction-03-lens-optimization.html
Ansys Optics, How to Prevent the Merit Function from Violating an Operand: https://optics.ansys.com/hc/en-us/articles/43071083515283-How-to-prevent-the-Merit-Function-from-violating-an-operand
The teaching chapter and official vendor guidance were opened. The weighted calculation and scanning-device case are original illustrations, not software-specific defaults.
Previous: Merge-scan Next: Mesh subdivision