System designHow-to

How to practice machine vision with offline images

Learn how to practice machine vision with recorded images, controlled lighting tests and held-out validation before selecting production hardware.

LumaSpec Vision10 min read Share on LinkedIn

On this page 10 sections
  1. 01Choose a legal offline workflow
  2. 02Build a labeled dataset without leakage
  3. 03Size the image before tuning tools
  4. 04Build a baseline inspection with visible evidence
  5. 05Run a controlled image-formation experiment
  6. 06Score held-out parts rather than familiar frames
  7. 07Choose physical parts after measuring the gaps
  8. 08Check the limits before calling it production-ready
  9. 09Make the next experiment repeatable
  10. 10Questions

Learning machine vision requires two connected exercises: processing recorded images and making repeatable images of real parts. Offline work teaches segmentation, measurement and decision logic without requiring a complete inspection station. A small bench experiment then exposes the lighting, focus and exposure problems that software alone cannot resolve. This workflow gives you a measurable learning project, a fair validation method and a basis for choosing hardware only after identifying what limits your results.

  1. Select software that can load saved images, apply processing tools and export inspection results.

Use freely licensed software from its publisher’s official distribution, or manufacturer-provided software with documented offline operation. Check whether image loading, emulation and result export require a separate license. If activation is required, follow the manufacturer’s process rather than assuming offline operation removes that requirement.

You do not need camera connectivity for the first exercise. Useful capabilities include grayscale conversion, regions of interest, thresholding, connected-component analysis, overlays and saving numerical results. A graphical tool and a programming library can both teach these fundamentals; neither approach automatically provides a production-ready inspection.

Choose one narrow task: decide whether a flat sample has a required dark mark. Include acceptable marks, absent marks and undersized marks. Write the acceptance rule before adjusting any processing settings.

Define the output as a decision plus evidence: pass or fail, detected area, mark position and a diagnostic image. The guide to turning inspection results into decisions explains why finding a feature and accepting a part are separate operations.

Build a labeled dataset without leakage

  1. Assemble images with known answers and divide them before tuning the inspection.

Use your own photographs or an image collection explicitly licensed for your intended use. Manufacturer training images are useful for learning controls, but a polished demonstration set does not establish performance on your parts.

For a manageable exercise, collect 100 distinct physical samples: 70 acceptable and 30 defective. Divide them as follows:

Dataset Acceptable samples Defective samples Purpose
Development 42 18 Build processing and choose thresholds
Validation 14 6 Compare approaches without touching the final test
Held-out test 14 6 Score the frozen inspection once

Keep every image of the same physical sample in the same partition. Otherwise, slightly different photographs of a familiar sample can make generalization look better than it is.

Record the sample identifier, label, defect reason, capture session and imaging settings. Include normal variations in position, surface finish and mark appearance. Artificially created defects are suitable for practice, but label them as artificial rather than treating them as representative production failures.

If you repeatedly adjust settings after examining validation results, that set gradually becomes development data. Preserve the held-out set until the inspection and acceptance limits are frozen.

Size the image before tuning tools

  1. Estimate the sampling needed to represent the smallest relevant feature.

Suppose the required horizontal field of view is 80 mm, and the smallest feature of interest is 0.4 mm wide. As an initial learning target, allocate 5 pixels across that feature:

Required horizontal pixels = field width × pixels per feature / feature width Required horizontal pixels = 80 mm × 5 / 0.4 mm = 1,000 pixels Object sampling = 80 mm / 1,000 pixels = 0.08 mm/pixel

This is a sampling estimate, not a guarantee of detection or measurement accuracy. Contrast, optical blur, noise and feature orientation still matter. Five pixels may support a simple presence test while being inadequate for a tight dimensional tolerance.

Camera resolution for the smallest feature
Units
Pixels needed
–
Sensor size
– MP
Smallest sensor that fits
–
Pixel on the part
– mm
Pixels across the feature, that sensor
–

Pixels needed = field / feature × pixels per feature on each axis (field incl. margin). The lens must resolve the pixels too: Nyquist = 1000 / (2 × pixel µm) lp/mm.

Find cameras with enough pixels Open the full calculator

Field of view depends on the sensor, lens and imaging geometry. Cropping an existing photograph does not recover detail that the original optics failed to capture.

How sensor width, working distance and field of view set the focal length Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.CameraField of view (FOV)Working distance (WD)≈ fsensor width slensm = s / FOVf = WD × m / (1 + m)
How sensor width, working distance and field of view set the focal length. Rays from the edges of the sensor pass through the lens and spread to the edges of the field of view. The ratio of sensor width to field of view is the magnification m.

Measure actual image dimensions rather than choosing by total megapixels alone. For the optical selection stage, use the lens focal-length selection guide. If the task becomes dimensional measurement, follow the separate image-marker calibration workflow rather than assuming a nominal pixel scale is sufficient everywhere.

Build a baseline inspection with visible evidence

  1. Create the simplest processing sequence that expresses your acceptance rule.

For the dark-mark exercise, use this sequence:

  • Load the image and confirm its dimensions and orientation.
  • Locate the sample or use a fixed inspection region when positioning is controlled.
  • Convert to grayscale consistently if color is not part of the decision.
  • Separate the dark mark from the background.
  • Measure connected regions by area, position and shape.
  • Apply acceptance limits and save an annotated result.

A basic threshold can be written as:

Foreground(x, y) = 1 when intensity(x, y) < T Foreground(x, y) = 0 otherwise

For an illustrative grayscale image with values from 0 to 255, suppose development measurements place the mark between 35 and 65 and the background between 160 and 210. A threshold near 110 is a reasonable starting hypothesis, not a universal setting.

Inspect the binary image before trusting its area measurement. Reflections may split the mark, while shadows may merge it with unrelated features. The binary preview workflow for defect inspection helps make these failures visible.

Avoid adding filters merely because a difficult image fails. Each processing stage should address an observed cause. Save the original image alongside intermediate results so you can distinguish poor image formation from an unsuitable decision rule.

Run a controlled image-formation experiment

  1. Re-image development samples while changing one physical variable at a time.

Use a stationary sample, a rigid camera support and a repeatable background. An existing camera is enough to demonstrate the effects, provided you can lock relevant settings. This experiment teaches image formation; it does not certify that the camera is suitable for production.

Start from one documented baseline, then compare these changes:

Variable Controlled change What to inspect
Lighting direction Move illumination while keeping exposure fixed Reflections, shadows and mark contrast
Focus Compare best focus with slight deliberate defocus Edge spread and measured area
Exposure Test 0.5×, 1× and 2× the baseline duration Clipping, noise and segmentation stability
Sample position Move and rotate within the allowed placement range Localization errors and background interference
Sample variation Repeat with different finishes and mark appearances Separation between acceptable and defective results

Use only development samples for exploratory adjustments. Once the capture procedure is fixed, acquire validation and held-out samples under the declared conditions without using their results to retune it.

Disable automatic controls during the controlled experiment. Otherwise, exposure or gain changes can conceal the effect of moving a light. The guide to iris, exposure and gain control explains which controls change image brightness and which also affect optical behavior.

For a moving-part extension, estimate blur before buying hardware:

Blur in pixels = object speed × exposure time / object sampling Maximum exposure = allowed blur × object sampling / object speed Maximum exposure = 1 pixel × 0.08 mm/pixel / 200 mm/s Maximum exposure = 0.0004 s = 0.4 ms

This estimate assumes motion across the image at the stated speed. It does not include rolling-shutter distortion, vibration or defocus. Shortening exposure also reduces collected light unless illumination or other settings change.

Score held-out parts rather than familiar frames

  1. Freeze the processing settings, then run the untouched test set.

Record false accepts and false rejects separately. A false accept passes a defective sample; a false reject rejects an acceptable sample. Define these terms explicitly because software packages may use different label conventions.

Suppose the held-out set contains 14 acceptable samples and 6 defective samples. The inspection rejects one acceptable sample and passes one defective sample:

False-reject rate = 1 / 14 × 100 = 7.1% False-accept rate = 1 / 6 × 100 = 16.7% Overall accuracy = 18 / 20 × 100 = 90%

The overall accuracy hides a substantial defective-sample escape rate. A small dataset also produces uncertain estimates: one additional missed defect changes this example’s false-accept rate considerably. Treat this as a learning result, not evidence of production capability.

Review errors by cause. Separate poor localization, glare, insufficient resolution, incorrect labels and overlapping feature measurements. If acceptable and defective samples produce overlapping areas, changing a single threshold may only exchange one error type for another.

If you revise the inspection after this review, the held-out set is no longer an untouched test. Collect a fresh independent set for the next final evaluation.

Choose physical parts after measuring the gaps

  1. Translate observed limitations into camera, lens and lighting requirements.

Browse area scan cameras through the camera finder after defining sampling, shutter behavior, interface and capture timing. For a stationary bench candidate, the LS-CMR-0053 provides a GigE interface and rolling shutter. Moving-part suitability requires a separate assessment.

Area scan cameras12 MP GigE area scan camera, IMX226, 1/1.7" rolling shutter, 9 fps (LS-CMR-0053)LS-CMR-0053
Sensor format
1/1.7"
Interface
GigE
Resolution
12 MP
Shutter
Rolling
$560.00View partBuild a system with it

Use machine vision lenses and the lens finder to match sensor coverage, mount, working distance and field of view. The LS-FFL-0567 is a C-mount lens candidate. Its inclusion here is not a confirmed optical pairing for your experiment.

Machine vision lenses16 mm, 1.1", 20 MP, C-mount Machine Vision Lens, 20 Megapixel, F2.8-22 (LS-FFL-0567)LS-FFL-0567
Type
Machine vision fixed
Sensor format
1.1"
Mount
C-mount
Resolution
16-25 MP
$679.00View partBuild a system with it

For front illumination, compare ring lights in the lighting finder. The LS-RNG-0143 is a diffused ring light. Test the illumination geometry on representative surfaces before treating diffusion as a solution to every reflection.

Ring lights100 mm dia. ring light with diffuser, 30° (LS-RNG-0143)LS-RNG-0143
Size
100-200 mm
Type
Diffused
Angle
30°
Voltage
24 V
$169.00View partBuild a system with it

These parts illustrate separate selection decisions, not a verified kit. Confirm lens focus range, optical coverage, mounting clearance, light opening, electrical connections and any required control hardware. Do not assume a light can connect directly to a camera output.

A larger image cannot restore contrast hidden by glare. A sharper lens cannot correct inconsistent triggering. Purchase against the failure you measured rather than increasing every specification together.

Check the limits before calling it production-ready

  1. Review what offline practice has demonstrated and what remains untested.

Before ordering, check the following:

  • Inspection definition: Document acceptable variation and every relevant defect category.
  • Sampling: Verify the smallest feature across the complete inspection region, including the corners.
  • Optics: Confirm working distance, focus adjustment, sensor coverage and mechanical clearance.
  • Lighting: Test difficult finishes, ambient-light changes and reflections at allowed part positions.
  • Acquisition: Check exposure, shutter behavior, trigger timing and the interval between required images.
  • Software: Confirm licensing, operating-system support, image formats and camera-interface compatibility.
  • Validation: Keep sample identities, capture sessions and final test data separate from tuning.
  • Integration: Define how results remain associated with the correct physical part.

Offline replay is the wrong final test when the main risk is motion, synchronization or changing image formation. It cannot reproduce trigger jitter, dropped frames or a vibration problem that was absent during recording. Use the external-trigger timing guide before extending the exercise to moving parts.

A ring light is also not the default answer for every surface. If reflections obscure the mark, revisit illumination geometry instead of forcing the threshold to accommodate missing information.

Make the next experiment repeatable

Keep a small project folder containing original images, labels, dataset assignments, capture settings, processing configuration and a results table. Add a short explanation of each failure and the next experiment intended to resolve it.

Your first milestone is not a convincing demonstration image. It is a frozen inspection that gives explainable results on unfamiliar samples, plus a clear account of its limits.

When the evidence points to a physical imaging limitation, start the camera configuration workflow or send the field of view, smallest feature, motion requirements and representative images through applications support. That information makes the next hardware decision more useful than a software preference alone.

Questions

Can I practice machine vision without buying a camera?

Yes. Saved images let you practice regions of interest, segmentation, measurements and acceptance rules without camera hardware. Use images with known labels and reserve unfamiliar samples for evaluation. You will still need physical capture experiments to understand focus, reflections, motion and acquisition timing.

What software capabilities do I need for offline practice?

Choose legally available software that loads image files, displays intermediate processing results and exports measurements. A graphical environment or a programming library can both work. Obtain it through the publisher’s official distribution and confirm any offline-mode, activation or evaluation restrictions before starting.

How many images should a beginner collect?

Start with enough distinct samples to separate development, validation and final testing while representing both acceptable and defective conditions. A hundred samples can support a useful learning exercise, but it does not establish production reliability. Rare defects and wide process variation require substantially broader evidence.

Why can an inspection pass saved images but fail on real parts?

Recorded-image results depend on the conditions represented in the dataset. A physical station introduces changes in illumination, placement, focus, motion and timing. If those changes were absent from training and testing, a fixed inspection may encounter images that its thresholds or localization tools cannot handle.

When should I move from offline practice to industrial hardware?

Consider hardware once you can state the required field of view, smallest feature, motion conditions and observed imaging limitations. Buying earlier can leave you solving the wrong problem. Confirm the camera, lens, illumination and mounting as a system rather than selecting each solely from its headline specifications.