GreatLight CNC Machining Factory logo
CNC Machining
Rapid Prototyping
Materials
Industries
News
About GL

Get Instant Quote

Imaging Pipeline Guide

What Are the Automatic Detection Steps for the Imaging?

A working walkthrough of the automatic detection steps for the imaging chain, written for engineers who have to make a detector, camera or inspection station actually hold its numbers. Each step lists the order of operations, the parameter ranges we use on real hardware, and the failure that shows up when a step is skipped or rushed.

Acquisition to registrationParameter rangesFailure modes
automatic detection steps for the imaging pipeline on an industrial edge system
Quick read

Key takeaways

Order mattersPreprocessing before feature extraction, registration before comparison. Swapping two steps costs more than tuning any single parameter.
Fix the input firstMost false detections trace back to acquisition geometry and lighting, not to the classifier.
Keep a held-out setTune on one batch, validate on a batch the algorithm has never seen. Otherwise the numbers lie.
Log every stageSave the preprocessed and segmented frames. Without them you cannot tell where a miss was born.
Know when to stopIf the source image is blurred past 2 px of motion, no post-processing will recover the defect.
Step 1

Image acquisition sets the ceiling for every later automatic detection step

Acquisition is where the automatic detection steps for the imaging chain either have room to work or do not. A CT slice, an MRI volume, an ultrasound frame or a mammogram all arrive as raw intensity values plus geometry metadata. If the exposure is clipped, the geometry is wrong, or the frame is motion-blurred, no downstream filter repairs it. We treat acquisition as a fixed constraint, not a tunable stage.

Start with pixel spacing and field of view. For surface inspection on a 5-axis machined part, we typically run 5–10 μm per pixel with a telecentric lens so that the scale does not drift across the field. For CT, isotropic voxels between 0.1 mm and 0.5 mm cover most medical and industrial work; below 0.05 mm the scan time and dose climb fast. Write the spacing into the file header. If the header and reality disagree, registration will be off by a voxel and you will chase a ghost defect.

Signal-to-noise is the next gate. A useful rule is that the contrast between the defect and its background should be at least 3× the local noise standard deviation. Below that, thresholding produces speckle and the detector reports noise as lesions. You can raise exposure, average more frames, or change modality. What you cannot do is filter your way out, because a linear filter raises contrast and noise together.

Blur is a hard limit. Motion blur beyond 2 px of travel across the exposure smears a 0.2 mm feature into the background. On a moving web or a rotating part, use a strobe or a short global-shutter exposure, and check the sharpness on a test target before you run production. A blurred frame that reaches feature extraction will burn hours of tuning for nothing.

  • 1
    Write spacing into the headerPixel or voxel size that disagrees with reality breaks registration silently.
  • 2
    Keep contrast above 3× noiseBelow that, thresholding reports noise as defects.
  • 3
    Cap motion blur at 2 pxStrobe or short global-shutter exposure on moving parts.
Step 2

Preprocessing normalizes the frames before detection runs

Preprocessing does three jobs: remove sensor artifacts, flatten uneven illumination, and bring every frame onto a common intensity scale. Do it in this order. First apply a dark-frame and flat-field correction using calibration frames captured at the same exposure and gain. This removes fixed-pattern noise and the vignette from the lens. Skipping flat-fielding is the single most common reason a detector works on one machine and fails on the next.

Next, denoise with an edge-preserving filter. A 3×3 to 5×5 median filter handles salt-and-pepper noise on ultrasound and on low-dose CT without smearing edges much. Bilateral or non-local means filters cost more compute but keep thin structures such as vessel walls and thread crests. Avoid a plain Gaussian blur for defect work. It lowers noise but rounds off the very corners and edges the detector is meant to find.

Then normalize intensity. Histogram equalization helps when contrast varies across a batch, but it also amplifies noise in flat regions. For parts with a known background, a simpler min-max stretch to 8-bit or a z-score normalization per frame is more predictable. Record the parameters you used. When a batch drifts, you need to know whether the cause was the optics or the stretch window.

Finally, resample to a fixed working resolution. If your training data was captured at 1200 × 1600 and production frames arrive at a different size, the feature scales will not match and the detection thresholds will be wrong. Resample once, at this stage, and keep the mapping so results can be projected back to full resolution for measurement.

  • 1
    Correct before you denoiseDark-frame and flat-field first; filters cannot fix a fixed-pattern gradient.
  • 2
    Pick an edge-preserving filterMedian, bilateral or non-local means. Not a plain Gaussian for defect work.
  • 3
    Resample onceMatch the training resolution and keep the mapping back to full size.
Step 3

Feature extraction turns pixels into numbers a detector can use

Feature extraction is where the image stops being an image. You are describing regions of interest with numbers: area, perimeter, circularity, elongation, gray-level mean and standard deviation, texture energy, and gradient magnitude along the boundary. For medical work, shape descriptors such as sphericity and margin sharpness separate benign from suspicious lesions more often than raw intensity does.

Choose features that survive the conditions you cannot control. If the part is re-fixtured between runs, avoid absolute position features and use shape and texture instead. If lighting drifts by 10 percent across a shift, use ratios and normalized contrast rather than absolute gray values. A feature that changes when nothing physical changed is a liability, no matter how well it separates your training set.

Texture features deserve care. Gray-level co-occurrence matrices and local binary patterns work well on cast surfaces, weld beads and tissue, but they are sensitive to the window size. A 5 × 5 window catches fine porosity; a 15 × 15 window catches tool marks and larger structures. Pick the window from the physical size of the defect, not from what looks good on screen.

The mistake to avoid is feature flooding. Adding forty features to a classifier with two hundred training samples produces a model that fits the noise. Keep the set small, check the correlation between features, and drop one of any pair above 0.9 correlation. Fewer, well-understood features are easier to explain to a customer and easier to defend in an audit.

  • 1
    Prefer shape and textureAbsolute position and absolute gray values break when fixtures or lighting drift.
  • 2
    Size the window to the defect5 × 5 for fine porosity, 15 × 15 for tool marks and larger structures.
  • 3
    Drop correlated featuresAny pair above 0.9 correlation: keep one, remove the other.
Step 4

Segmentation and registration decide where detection points

Segmentation partitions the frame into meaningful regions: a lesion against tissue, a pore against a casting, a thread against a shank. Otsu thresholding is fine when the histogram is bimodal and the background is flat. Adaptive or local thresholding handles uneven illumination but needs a window roughly 2–3× the size of the smallest feature. When objects touch, watershed or graph cuts separate them; watershed alone tends to over-segment textured surfaces, so merge the fragments afterward using an area rule.

Registration aligns frames captured at different times or from different modalities. For rigid alignment of a re-fixtured part, a phase-correlation or feature-based estimate followed by a fine fit gives a mean residual under 0.5 px in most cases. If the part deforms, or you are comparing a CT volume to an MRI volume, you need an affine or non-rigid step. Non-rigid registration can hide real defects by warping them onto the reference, so constrain the deformation and inspect the warp field.

The engineering meaning is simple: detection only works on aligned, comparable data. An unregistered subtraction flags every edge and every slight shift as a change, and the operator stops trusting the system within a week. Spend the time here. In our experience on machined and cast parts, registration quality moves the false-positive rate more than any classifier change.

Validate registration on parts you deliberately moved or re-fixtured. Measure the residual at three or more landmarks, not one. If the residual grows toward the edge of the field, your model is missing lens distortion; add a distortion correction before registration and re-check.

  • 1
    Match window to featureAdaptive thresholding window at 2–3× the smallest feature size.
  • 2
    Constrain non-rigid warpsAn unconstrained warp can bend a real defect onto the reference and hide it.
  • 3
    Check residuals at three landmarksGrowth toward the field edge means uncorrected lens distortion.
Step 5

Validation is the last of the automatic detection steps for the imaging chain

Validation is not a formality. Split your labeled data before you tune anything: roughly 70 percent for training, 15 percent for validation during tuning, and 15 percent held back until the end. The held-out set is the only honest measure of how the system will behave in production. If you tune on it, it stops being held out, and your reported numbers become fiction.

Track precision and recall separately, and per part family. A detector that catches every crack but flags forty good parts a day will be switched off by the line operator. A detector that never false-alarms but misses one in twenty defects is worse, because it ships bad parts. Decide which error you can live with before you set the threshold, and write that decision down.

Retrain when the input changes, not on a calendar. A new lamp, a new fixture, a new material lot or a sensor gain change all shift the feature distribution. Watch the score distribution and the low-confidence rate. A drift of more than 3 points in recall on a control batch is the signal to recheck preprocessing before you touch the model.

Keep the intermediate outputs: corrected frame, segmented mask, feature vector, classifier score. When a miss reaches the customer, these four artifacts tell you in minutes whether the problem was acquisition, segmentation, features or the model. Without them, every investigation restarts from zero.

  • 1
    Split before tuning70 / 15 / 15. The held-out set is touched once.
  • 2
    Report precision and recallPer part family, not as one blended number.
  • 3
    Retrain on input changeNew lamp, fixture, material lot or gain change.
  • 4
    Save four artifactsCorrected frame, mask, feature vector, score.
Runbook

The five automatic detection steps for the imaging pipeline, in order

Follow the sequence. Each step lists the parameters we set on real inspection and imaging systems, plus the error that shows up when the step is rushed.

  • 1
    1. Acquire and record geometryCapture at 5–10 μm per pixel for surface work, 0.1–0.5 mm isotropic voxels for CT. Write pixel spacing, exposure and gain into the header. Common error: running without a flat-field and dark-frame pair, which leaves a gradient that later steps read as a defect.
  • 2
    2. Preprocess and normalizeApply dark-frame and flat-field correction, then a 3×3 to 5×5 median or bilateral filter, then a min-max or z-score stretch. Resample to the training resolution once, here. Common error: Gaussian blurring thin edges you later need to measure.
  • 3
    3. Segment the region of interestUse Otsu or adaptive thresholding for high-contrast parts, watershed or graph cuts when objects touch. Check the result on at least 30 frames per part family. Common error: tuning the threshold on one lucky frame, then watching it fail across the batch.
  • 4
    4. Extract features and classifyCompute 8–15 shape, texture and intensity features per region. Feed a small model: a linear or SVM classifier for under 1,000 samples, a CNN when you have 5,000 or more labeled regions. Common error: training and validating on the same batch.
  • 5
    5. Register and compare against the referenceAlign to the baseline with a rigid transform first, then affine or non-rigid if the part flexes. Accept a mean residual under 0.5 px for rigid alignment. Common error: comparing an unregistered frame to a reference, which flags every edge as a change.
  • 6
    6. Review the output and close the loopSend passes, fails and low-confidence regions for human review. Track precision and recall per part family, and retrain when recall drops more than 3 points. Common error: never revisiting thresholds after a fixture or lamp change.
Method choice

Choosing a method for each automatic detection step

Pick by data volume, contrast and how much the part moves between captures.

StepMethodUse whenWatch out for
PreprocessingMedian 3×3Salt-and-pepper noise, low-dose CTRounds off thin edges
PreprocessingBilateral filterNeed edges kept, compute availableSlow on large volumes
SegmentationOtsu thresholdBimodal histogram, flat backgroundFails on uneven lighting
SegmentationWatershedTouching objects of similar sizeOver-segments texture
FeaturesShape and textureFixtures or lighting driftNeeds a clean segmentation
ClassifierSVM or linearUnder 1,000 labeled regionsWeak on raw pixels
ClassifierCNN5,000+ labeled regionsNeeds a held-out batch
RegistrationRigid, phase correlationSame part, re-fixturedIgnores deformation
RegistrationNon-rigidTissue or flexible partsCan warp defects away

Where this leaves you

If the acquisition is clean and the frames are registered, the detection problem is usually small. If either is weak, no amount of model tuning will save the project. Fix the front of the chain first.

FAQs

Questions engineers ask about these steps

How many labeled images do I need before detection works?

For a simple, high-contrast defect with a handful of shape features, a few hundred labeled regions can be enough. A CNN typically wants 5,000 or more labeled regions, and more importantly a held-out batch that reflects production variation.

Count part families, not just images. Ten thousand frames of one part with one lamp teaches the model very little about the next part.

Can I run these steps on an edge device instead of a server?

Yes, if you keep the model small. Median and bilateral filtering, Otsu segmentation and an SVM classifier all run comfortably on modest edge hardware. A large CNN usually does not.

A common split is to preprocess and segment at the edge, then send only regions of interest to a server for classification. That cuts bandwidth and keeps latency predictable.

Why does my detector work in the lab and fail on the line?

Almost always the input changed: different lighting, a re-fixtured part, a new material lot, or a camera gain that was reset. The model did not get worse; the features moved.

Compare the corrected frame and the feature vector between lab and line. The stage where the two diverge is the stage to fix.

Is non-rigid registration safe for defect detection?

It is necessary when the part deforms between captures, but it carries a real risk: an unconstrained warp can bend a genuine defect onto the reference and erase it from the difference image.

Constrain the deformation to what the material can physically do, and inspect the warp field as part of validation.

How often should thresholds be revisited?

After any change to optics, fixtures, materials or camera settings, and otherwise on a scheduled check using a control batch. A drop of more than 3 points in recall on that batch is the trigger to investigate.

Do not retrain on a calendar alone. Retraining on unchanged data adds cost and risk without improving anything.

Send us the frames and the spec

We review imaging and inspection hardware requirements, quote within 12 hours, and run 100% inspection before shipment.

12-hour quote100% inspectionNDA on request

Follow

More from GreatLight

We publish setup notes, tooling trials and inspection data from the factory floor.

FacebookTikTokYouTubeLinkedInInstagramThreadsPinterest

Trusted by engineers and manufacturers worldwide

Tesla Ford Motor Company BYD Auto Denso Magna International Boeing Airbus Medtronic KUKA FANUC