DIP+CV · Programming Exercise

EP06_03 — 🟡 Classification of Markings on Answer Sheets (OMR)

6.14.3 EP06_03 🟡 Classification of Markings on Answer Sheets (OMR)

After sheet rectification and segmentation of answer frames, MCTest estimates, for each bubble, a fill degree, represented by a value between \(0\) and \(100\). Based on these values, the system must automatically determine the marked alternative, also identifying blank questions and cases of multiple markings.

In this exercise, you will implement this decision stage of the OMR pipeline. The classification depends on a fill threshold: small variations in this value can alter the result of automatic reading.

6.14.3.1 📋 Implementation Guidelines

  1. Parameters: Read integers \(Q\) (number of questions) and \(K\) (number of alternatives per question, with \(2 \le K \le 26\)) and the fill threshold \(\mathrm{Th}\) (a real number between \(0\) and \(100\)).
  2. Fill degrees: For each of the \(Q\) questions, read the \(K\) real values corresponding to alternatives A, B, C, …, in input order.
  3. Counting markings: For each question, count how many alternatives have a fill degree strictly greater than \(\mathrm{Th}\).
  4. Classification:
    • If no alternative exceeds \(\mathrm{Th}\), classify the question as BRANCO.
    • If exactly one alternative exceeds \(\mathrm{Th}\), print the corresponding letter (A, B, C, …).
    • If two or more alternatives exceed \(\mathrm{Th}\), classify the question as DUPLA_MARCACAO.
  5. Output per question: Print, in reading order, the classification of each question.
  6. Totals: Finally, print the number of questions OK (single marking), BRANCO, and DUPLA_MARCACAO.

6.14.3.2 📌 Computational Constraints

  • Strict comparison: only values greater than \(\mathrm{Th}\) are considered valid markings; values exactly equal to the threshold must not be counted.
  • Alternative letters: index \(0\) corresponds to alternative A, index \(1\) to alternative B, and so on.
  • Multiple markings: whenever two or more alternatives exceed the threshold, the classification must be DUPLA_MARCACAO, regardless of their respective fill degrees.

6.14.3.3 🧠 Theoretical Foundation

Situation Classification Interpretation
Exactly one alternative above the threshold Letter of the alternative Valid answer
No alternative above the threshold BRANCO Unanswered question
Two or more alternatives above the threshold DUPLA_MARCACAO Ambiguous answer

The fill threshold controls the sensitivity of the algorithm. Very low values tend to increase the number of DUPLA_MARCACAO, while very high values may increase the number of questions classified as BRANCO.

6.14.3.4 📦 Input and Output Specification (VPL)

Input:

  • Line 1: Integer \(Q\).
  • Line 2: Integer \(K\).
  • Line 3: Real number \(\mathrm{Th}\).
  • Next \(Q\) lines: \(K\) real numbers, corresponding to the fill degrees of the alternatives.
  • Line 1: Integer \(Q\) and \(K\).

Output:

  • \(Q\) lines, each containing the classification of the respective question.
  • Final line: OK: x BRANCO: y DUPLA_MARCACAO: z.

6.14.3.5 📌 Examples

Input Output Observation
3
4
50
10 85 5 12
20 15 18 22
90 88 10 5
B
BRANCO
DUPLA_MARCACAO
OK: 1 BRANCO: 1 DUPLA_MARCACAO: 1
In the first question only B exceeds the threshold; in the second, no alternative exceeds it; in the third, A and B exceed the threshold.
1
2
50.0
50 50
BRANCO
OK: 0 BRANCO: 1 DUPLA_MARCACAO: 0
Values equal to the threshold are not considered valid markings.
🎮 Simulator EP06_03: OMR Mark Classification 4 Alternatives
Adjust the fill level of each bubble (A–D) and the threshold to observe the resulting classification.
–
Figure 6.23: EP06_03 Simulator: OMR Mark Classification
%%writefile EP06_03.py
# Python code
Overwriting EP06_03.py
TestSuite("EP06_03.py").run()
✔️ EP06_03.cases already exists in casos/
📋 5 case(s) loaded from casos/EP06_03.cases

🔍 Testing Python: EP06_03.py
⚠️ EP06_03.py: Empty file (fewer than 3 lines). Tests skipped.