Image Processing
A manufacturer wants to inspect parts with a camera. Today the first question is often: do we need AI for this? Sometimes yes. But classic methods frequently solve the task faster, cheaper and more transparently – and the wrong choice costs months, in either direction.
Two tools, two ways of thinking
Classic image processing works with rules that a developer defines: filters, thresholds, edges, contours and geometry. Libraries such as OpenCV or Halcon provide proven building blocks for this. Every step can be measured and explained.
Machine learning, and deep learning in particular, learns the rules from sample images. A neural network finds features on its own – including features that are hard to put into words. In return it needs data, computing power and careful validation.
The decision in five questions
- Can the defect be described? If you can say in one sentence how a defect is recognised (“hole missing”, “edge too short”), that points to classic methods.
- How much do parts and surroundings vary? Natural objects, changing surfaces and unstable lighting point to learning methods.
- Are there enough sample images? Above all of defects. Rare defects are hard to learn.
- How much computing power is available? An industrial PC with a graphics card is very different from an embedded system inside the camera.
- Do you have to justify decisions? In regulated fields such as medical and laboratory technology, traceability matters.
Decision guide at a glance
| Criterion | Classic image processing | AI / deep learning |
|---|---|---|
| Measuring dimensions, positions, angles | very well suited, sub-pixel accuracy possible | usually only as a supplement |
| Defect clearly describable | first choice | possible, often oversized |
| Variable surfaces, natural objects | laborious, many special rules | strength of learning methods |
| Data required | a few sample parts | many carefully labelled images |
| Computing power | low to medium | medium to high, often with GPU or AI accelerator |
| Traceability | every step explainable | limited, needs targeted validation |
| Product changes | adjust parameters | possibly retrain |
A classic approach in a few lines
This example with Python and OpenCV shows how little code a rule-based check often needs. It separates parts from the background with an automatic threshold and reports their position and size:
import cv2
image = cv2.imread("part.png", cv2.IMREAD_GRAYSCALE)
image = cv2.GaussianBlur(image, (5, 5), 0)
_, mask = cv2.threshold(image, 0, 255, cv2.THRESH_BINARY + cv2.THRESH_OTSU)
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for contour in contours:
area = cv2.contourArea(contour)
if area < 500:
continue # ignore small specks as noise
x, y, width, height = cv2.boundingRect(contour)
print(f"Part at ({x}, {y}): {width} x {height} pixels, area {area:.0f}")
With even lighting and a high-contrast background, something like this is often enough for a robust presence or size check. Against strongly varying surfaces, however, it does little.
The middle way: combine
In practice the answer is often “both”. Classic steps find and measure the part, and a small network only assesses the difficult surface. Or the other way round: a network locates objects, and geometry then checks them exactly. This keeps the AI share small, fast and easy to verify.
An example from our projects: for a manufacturer of thermal imaging cameras, faces had to be located in the image – on an embedded system with very limited computing power. We examined various algorithms and neural networks for speed and detection quality. In the end, our own lean methods ran in real time on the hardware and reliably distinguished faces from lamps and other heat sources. Compute-heavy AI was not an option there. When evaluating 3D point clouds for a sensor manufacturer, we also recognised shapes such as cylinders, cuboids and spheres with geometric methods like RANSAC – without a neural network.
Common mistakes
- Choosing AI because it sounds modern, although a threshold and a contour check would do.
- Refining classic rules further and further until nobody can follow them, instead of switching to a learning method in time.
- Neglecting lighting and optics. No algorithm can rescue a poor image.
- Collecting too few defect images and testing the model only with good parts.
- Choosing the target hardware at the very end. By then the method often no longer fits the device.
- Starting without measurable acceptance criteria: which detection rate, which cycle time and how many false alarms are acceptable?
How we help
- Image processing feasibility study: using your sample parts, we check whether classic methods, AI or a combination solve the task best – with a reliable result before you invest.
- Implementation: image processing with OpenCV, Halcon, PCL or neural networks in C#, C++ or Python, up to integration into your device or machine.
- Your project: Request a project or book an initial consultation
- Case study: Thermal imaging cameras: finding faces on limited hardware
From our projects in sensor, laboratory and measurement technology: face detection on thermal imaging cameras with embedded hardware, object recognition in 3D point clouds with OpenCV, PCL and Halcon.
