Is it possible to detect blur, exposure, orientation of an image programmatically?
ML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.
Introduction
Yes, blur, exposure problems, and orientation can all be detected programmatically, but not with one magic formula. In practice, you combine several measurable signals and calibrate thresholds against real sample images from your own camera sources.
Blur Detection Usually Uses Sharpness Metrics
A common blur heuristic is Laplacian variance. The idea is simple: sharp images contain stronger edge detail, and that produces a higher variance after applying a Laplacian operator.
This is a strong baseline, but the threshold is not universal. A value that works for scanned documents may fail for night photos or low-resolution thumbnails.
Exposure Detection Should Look Beyond Average Brightness
Mean brightness alone is often misleading. Two images can have the same average brightness while one is badly clipped in highlights and the other is too dark in shadows.
A better quick check is to measure how many pixels fall near black and near white.
This is still heuristic logic, but it is more informative than a single brightness average.
Orientation Can Often Come from Metadata First
For many mobile photos, EXIF metadata already records orientation. Reading that metadata is usually the fastest first step.
If metadata is missing or stripped, then you need content-based methods such as text direction, face orientation, or horizon detection depending on the type of image.
Combine the Signals Instead of Seeking One Score
In real systems, the best approach is usually a small rule set, not a single “image quality number.” For example:
- reject when blur is severe
- warn when exposure is borderline
- auto-rotate when EXIF says the image is sideways
- send uncertain cases to a slower review path or human check
That layered design is easier to tune than one oversimplified pass-fail metric.
Calibration Matters More Than the Formula Name
A major production lesson is that thresholds copied from examples are rarely reliable on their own. Device cameras, compression, resolution, and lighting conditions all affect the measurements.
The practical way to tune the system is:
- collect sample images from your real pipeline
- label them as acceptable or unacceptable
- measure your blur and exposure metrics
- choose thresholds that balance false rejects and false accepts
Without that calibration step, even a sensible algorithm can behave badly.
Common Pitfalls
The most common mistake is assuming one blur threshold fits every image source. It usually does not.
Another pitfall is using only average brightness for exposure decisions. That misses clipped highlights and crushed shadows.
Teams also often trust EXIF orientation too much. It is a strong first step, but metadata may be stripped or wrong in some upload paths.
Finally, image quality checks should be treated as heuristics with confidence, not as perfect truth. If the cost of rejection is high, keep room for a fallback or review path.
Summary
- Blur, exposure, and orientation can all be detected programmatically.
- Laplacian variance is a common and effective baseline for blur detection.
- Exposure checks are more reliable when they inspect dark and bright pixel ratios, not just average brightness.
- EXIF metadata is the fastest first step for orientation correction.
- Real reliability comes from combining signals and calibrating thresholds on your own image data.
Related reading
- Is it possible to use image_dataset_from_directory with convolutional autoencoders in Keras?
- Is there a function to extract image patches in PyTorch?
- Is there a way to get the color of a recognized object inside a picture?
- Is there an algorithm to determine contiguous colored regions in a grid?
- Is there an efficient algorithm for segmentation of handwritten text?
- Is there any good open-source or freely available Chinese segmentation algorithm available?
- Is there any simple way to test two PNGs for equality?
- Is there any super fast algorithm for finding LINES on picture?
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseNo course covers this one yet
Basis Lab writes one for you from a sentence about what you want to be able to do, then teaches it and checks you understood. Your first course is free.
Build my courseML System Design practice on Codemia
Design recommenders, ranking systems and training pipelines the way ML interviews actually ask for them, with worked solutions.