A line drawn across a biscuit is useful diagnostic evidence, but it is not yet a reliable crack decision. Baked texture, embossed patterns, shadows and the outer rim can also produce strong edges. This explainer is for inspection developers moving from an annotated image to an automatic result. You will learn how to interpret line outputs, restrict them to the product, define measurable acceptance rules and validate the result under production variation.
1. Make the decision from measurements, not the overlay
Keep the original image, numerical detections and display overlay separate. The overlay is a visualization generated after detection; its color and thickness are arbitrary drawing settings. Counting its colored pixels measures how the software drew the lines, not how much physical cracking exists.
A useful inspection sequence is:
- Acquire an image and check that it is usable.
- Locate the biscuit and build its inspection mask.
- Extract edges and generate line candidates.
- Measure candidate length, position and supporting evidence.
- Apply the validated defect rule.
- Report the decision and retain diagnostic measurements.
Use explicit output states such as CRACK_DETECTED, PASS and REVIEW. A missing image, failed product location or unexpected result format belongs in REVIEW, not PASS.
The distinction between numerical results and display annotations also appears in live-feed circle detection. Here, however, the objective is defect classification rather than identifying a geometric shape.
2. Understand what the line function returns
Check the documentation for the exact function and binding you use. Two common Hough interfaces produce different kinds of evidence:
| Output style | Typical values per detection | What you can measure directly | Main limitation |
|---|---|---|---|
| Standard line transform | Distance rho and angle theta
|
Orientation and distance from the image origin | Represents an infinite line, not a finite crack |
| Probabilistic segment transform | Endpoints x1, y1, x2, y2
|
Segment position, orientation and length | Segments can split, overlap or bridge gaps |
Some bindings wrap each detection in an extra array dimension. Others return a list, an array or an empty-result sentinel. Inspect the type and shape using known test images before writing the decision logic.
A standard Hough line is commonly represented by:
This equation does not tell you where the crack begins or ends. To estimate finite support, examine the edge pixels near that line inside the inspection region. Drawing a long line across the image does not establish a correspondingly long defect.
For endpoint-based segments:
Neither output format directly provides crack width, depth or certainty. A Hough detection means that edge evidence supports a line-like structure under the selected parameters.
3. Handle empty results without hiding acquisition faults
An empty result is normal when no candidate satisfies the transform settings. It can also occur when the image is blurred, underexposed or incorrectly masked. Those situations must not become indistinguishable.
First evaluate image validity and product location. Then normalize the detector output into a consistent segment list. Check documented empty-return forms explicitly; do not rely on the truth value of an arbitrary numerical array.
The following is language-neutral pseudocode, not a drop-in API example:
if image_invalid or product_location_failed:
decision = REVIEW
else:
raw_result = run_segment_detector(inspection_edges)
segments = normalize_documented_result(raw_result)
measurements = measure_and_filter(segments, inspection_mask)
if any_candidate_meets_crack_rule(measurements):
decision = CRACK_DETECTED
else:
decision = PASS
print(decision)
Here, PASS means that no qualifying evidence was found within a valid, validated inspection. It does not mean the biscuit is guaranteed free of every possible crack.
During development, also log candidate count, longest supported segment, rejected-candidate reasons and image-validity status. These values explain a result far better than a terminal message alone.
4. Build a product mask and separate perimeter inspection
Locate the biscuit independently of the suspected crack. Depending on product appearance, that may involve foreground segmentation, a fitted outline or a recipe-specific locator. Reject or review images where the expected product is missing, clipped or poorly located.
Create an interior inspection mask by moving inward from the detected perimeter. This excludes the strong outer edge and some nearby shadows. Choose the exclusion distance from measured positioning variation and the defect specification, not simply from what makes one example look clean.
A useful processing order is to extract edges from the original image, then apply the interior mask to the edge map. Setting the background to black before edge extraction can create an artificial boundary around the mask.
For every candidate, check that its evaluated path lies in the permitted region. Endpoints inside the mask are insufficient when the path crosses a hole or excluded area.
Keep separate rules for interior cracks, rim breaks and missing material. They have different visual signatures and should not be forced through one straight-line threshold.
5. Convert pixel evidence into an acceptance rule
Define the defect specification before selecting thresholds. A practical starting rule might require a minimum supported length, sufficient local edge support and acceptable separation from known texture features.
Measure more than the longest detected segment:
- Supported length: the portion associated with actual image evidence, rather than the displayed line extent.
- Support fraction: the proportion of sampled positions along a candidate that have nearby qualifying edge evidence.
- Position: whether the candidate belongs to the interior or perimeter inspection.
- Local contrast: whether the feature differs sufficiently from its immediate surroundings.
- Continuity: whether gaps are consistent with the accepted crack appearance.
Define how wide a neighborhood counts as nearby edge support. A wider neighborhood tolerates localization error but can collect unrelated texture. Freeze that setting with the rest of the recipe.
For an approximately front-facing surface with a known field of view, a first sampling estimate is:
This scale estimate assumes approximately uniform magnification over the inspected surface. Perspective, lens distortion and product height variation can require calibration or position-dependent conversion.
Use the camera resolution calculator to estimate sampling needs. Sampling alone does not prove that the optics and lighting resolve a crack.
Worked example: an illustrative length rule
Suppose the horizontal field of view is 120 mm across an image containing 2400 horizontal pixels:
A detected segment measuring 96 pixels would represent approximately 4.8 mm. If 78 of its 96 evaluated sample positions have nearby edge support, its support fraction is 78 / 96 = 81.25%.
An illustrative rule requiring at least 80 pixels and 75% support would accept that segment as qualifying evidence. These are example settings, not validated biscuit acceptance limits. Confirm them against the smallest rejectable cracks and the strongest intact-product texture.
6. Control texture, duplicated edges and fragmented cracks
Baked texture can create many short segments. Embossed lettering may create long ones. A single length threshold rarely separates every intact biscuit from every cracked biscuit.
Compare candidate behavior across labeled samples. If intact texture generates many short segments but cracks produce connected paths, evaluate connectivity rather than lowering the minimum length indiscriminately. If embossing causes false positives, consider a product-aligned exclusion region, provided that excluding it does not hide required defects.
A crack can produce edges on both sides. Summing every segment length may therefore count one defect twice. Overlapping detections can inflate the total further. Measure the union of supported paths or group overlapping segments before calculating total extent.
Conversely, a curved crack may appear as several short segments. Grouping can help, but unrestricted grouping also joins unrelated crumbs and texture. Define maximum endpoint gaps and orientation changes from labeled examples, then test those rules on intact products.
Thresholding that preserves values above a cutoff is not necessarily a binary segmentation step. Verify the actual preprocessing output before interpreting its effect on the edge detector. Increasing an edge threshold may remove weak texture while also removing the faint cracks you need to detect.
7. Trial lighting before adding more decision rules
Poor crack contrast cannot reliably be repaired by extra Hough parameters. Compare lighting arrangements with the camera position, exposure and sample set controlled.
Directional bar lights can create shadows or contrast at surface discontinuities. The response depends on crack direction, surface shape and illumination angle. Test opposing directions or separate directional exposures when one orientation hides defects.
The LS-2LB-300X16 is a bar-light candidate for evaluating directional illumination.
- Size
- 200-400 mm
- Type
- Standard
- Voltage
- 24 V
Diffuse dome lights illuminate from many directions and can reduce uneven reflections. They may make the baked surface easier to segment, but they can also weaken the directional shadows that reveal a shallow crack. The dome lighting guide explains that tradeoff and the importance of illumination coverage.
The LS-3DM14330 is a dome-light candidate for the diffuse-illumination trial.
- Size
- 100-200 mm
- Voltage
- 24 V
Use the lighting finder to compare arrangements after establishing which geometry separates defects from normal texture. Confirm optical clearance, mounting, cleaning requirements and compatible control before ordering.
The method in controlled-image scratch inspection is also useful here: change one imaging condition at a time and preserve representative images for comparison.
8. Match the camera to the smallest relevant feature
Choose among area scan cameras using field of view, required sampling, exposure time and product motion. A higher pixel count cannot recover detail lost through blur, poor focus or inadequate contrast.
For moving products, estimate motion blur in object coordinates:
At 200 mm/s with a 0.5 ms exposure, motion during exposure is 200 × 0.0005 = 0.1 mm. At the example sampling of 0.05 mm/pixel, that corresponds to approximately 2 pixels of blur. Whether this is acceptable depends on the minimum crack appearance and validated detection margin.
The LS-MV-133GM-GE is a monochrome, global-shutter example to evaluate against your imaging requirements.
- Sensor format
- 1/2.7"
- Interface
- GigE
- Resolution
- Up to 3 MP
- Shutter
- Global
Do not assume that this example meets the worked sampling scenario. Compare actual image dimensions, acquisition timing and integration requirements through the camera finder. For moving inspections, also review camera selection for conveyor speed and blur.
9. Validate the complete inspection, not a selected image
Build a labeled sample set containing intact products, obvious cracks and borderline defects. Include baked-color variation, embossing, crumbs, product rotation and the expected range of positions and heights.
Separate development samples from final validation samples. Keep repeated images of the same physical biscuit in the same group; otherwise, apparently independent results can be misleading.
Track at least two different errors:
For example, rejecting 8 of 400 intact biscuits gives 8 / 400 = 2%. Passing 3 of 100 cracked biscuits gives 3 / 100 = 3%. These are illustrative observed rates, not performance claims or guarantees for future production.
Report review outcomes separately. Also split results by defect class: a good overall result can hide poor detection of faint, curved or rim-originating cracks.
Freeze exposure, lighting, masks and thresholds before the final validation run. Revalidate after changes that affect image formation or decision logic. The software upgrade validation checklist provides a useful framework for preserving reference images and checking changed behavior.
10. Check the recipe before production use
Before connecting the decision to product rejection, confirm the following:
- Empty detections are handled without exceptions or ambiguous array checks.
- Invalid images and missing products produce a defined review or fault outcome.
- Display drawing settings cannot change the classification.
- Perimeter exclusions do not silently remove required defect coverage.
- Duplicate segments do not inflate crack length.
- Curved and interrupted cracks are represented in the validation set.
- Lighting trials include intact texture as well as cracked samples.
- Each result remains associated with the correct physical product through rejection.
- Saved diagnostics contain the image, recipe version, measurements and final decision.
Straight-line detection is the wrong primary method when required defects are mostly branching, curved, low-contrast or visually indistinguishable from normal texture. In those cases, evaluate connected-path analysis, other image features or a trained classifier against the same labeled validation set. Changing algorithms does not remove the need for controlled imaging and measurable acceptance criteria.
Start the camera configuration process once field of view and sampling are defined, or use application support to review sample images, lighting options and the defect specification before selecting parts.
Questions
Can counting red overlay pixels identify a cracked biscuit?
No. Overlay color and line thickness are display choices, so their pixel count is not a physical defect measurement. Use the numerical detector output and supporting image evidence instead. Keep annotations downstream of classification so changing the display cannot change the inspection result.
What should an empty Hough result mean?
First check that acquisition, exposure and product location succeeded. Then interpret the documented empty return as no candidate evidence under the current settings. Only assign a pass when the complete inspection is valid and its sensitivity has been established using representative cracked samples.
Is a minimum line length enough for biscuit crack detection?
Length is useful when defects are approximately straight and physically distinguishable from normal texture. It is insufficient when embossing creates long edges or cracks split into short sections. Combine length with location, local support and continuity, then evaluate false rejects and missed defects independently.
Should crack inspection use directional or diffuse lighting?
Neither geometry is automatically better. Directional illumination can reveal surface discontinuities but may hide cracks aligned unfavorably to the light. Diffuse illumination can stabilize surface appearance while reducing useful shadows. Compare both using the same intact and cracked samples under controlled camera settings.
How should camera resolution be selected for crack inspection?
Calculate the sampling needed for the smallest relevant feature across your field of view, then check actual image contrast and blur. More pixels will not fix poor focus or ineffective illumination. Confirm detection on representative minimum-size defects rather than selecting resolution from crack length alone.


