0
0
Computer Visionml~8 mins

Image thresholding (binary, adaptive, Otsu) in Computer Vision - Model Metrics & Evaluation

Choose your learning style9 modes available
Metrics & Evaluation - Image thresholding (binary, adaptive, Otsu)
Which metric matters for Image Thresholding and WHY

In image thresholding, the goal is to separate objects from the background clearly. The key metric is accuracy of pixel classification: how many pixels are correctly labeled as foreground or background. This is important because a good thresholding method should minimize mistakes in pixel labeling to produce a clean binary image.

For adaptive and Otsu thresholding, metrics like precision and recall on foreground pixels help understand if the method captures the object well without including too much background noise.

Confusion Matrix for Pixel Classification
      | Predicted Background | Predicted Foreground |
      |----------------------|----------------------|
      | True Negative (TN)    | False Positive (FP)   |
      | False Negative (FN)   | True Positive (TP)    |

      Total pixels = TP + FP + TN + FN

      Example:
      TN = 9000 (background pixels correctly identified)
      FP = 500  (background pixels wrongly marked as foreground)
      FN = 300  (foreground pixels missed)
      TP = 1200 (foreground pixels correctly identified)
    
Precision vs Recall Tradeoff in Thresholding

Precision tells us how many pixels labeled as foreground are actually foreground. High precision means less background noise in the object.

Recall tells us how many actual foreground pixels were detected. High recall means the object is fully captured.

For example, in medical imaging, missing parts of a tumor (low recall) is worse than including some background (lower precision). So recall is more important.

In document scanning, including background noise (low precision) can make text unclear, so precision is more important.

Good vs Bad Metric Values for Image Thresholding
  • Good: Accuracy above 95%, Precision and Recall both above 90%, meaning most pixels are correctly classified with minimal noise and missing parts.
  • Bad: Accuracy below 80%, Precision or Recall below 70%, indicating many pixels are wrongly classified, causing noisy or incomplete binary images.
Common Pitfalls in Thresholding Metrics
  • Accuracy paradox: If background pixels dominate, high accuracy can be misleading even if foreground detection is poor.
  • Ignoring class imbalance: Foreground pixels are often fewer; metrics like precision and recall are better than accuracy alone.
  • Overfitting threshold: Choosing a threshold that works only on one image but fails on others.
  • Data leakage: Using test image info to pick threshold biases results.
Self Check: Is 98% Accuracy but 12% Recall Good?

No, this is not good. The model correctly labels most pixels overall, but it only finds 12% of the actual foreground pixels. This means it misses most of the object, which defeats the purpose of thresholding. High recall is crucial to capture the full object.

Key Result
In image thresholding, precision and recall on foreground pixels are key to evaluate how well the object is separated from background, beyond overall accuracy.