🎛️ EP01_07 Simulator: Interactive Image Thresholding
Binary: 0 or 255
128
Input (Grayscale)
Output (Binary Mask)
Pixels with intensity greater than 128 (p > 128) become white (255); otherwise, they become black (0).
In this activity, you must write a program that performs image segmentation through thresholding.
\[\text{result} = \begin{cases} 255 & \text{if } p > T \\ 0 & \text{if } p \le T \end{cases}\]
📌 Important:
Thresholding is the simplest method for separating objects of interest from the image background. By converting grayscale tones into pure black and white, we create a binary map that facilitates object counting or shape identification:
| Pixel Value (\(p\)) | Condition | Final Result |
|---|---|---|
| Dark (\(p \le T\)) | Background/Noise | 0 (Black) |
| Light (\(p > T\)) | Object/Highlight | 255 (White) |
Input:
The first line contains the integer L.
The second line contains the integer C.
The third line contains the integer T (threshold).
The following lines contain the elements of the matrix.
Output:
The binarized matrix (0 or 255) with L rows and C columns.
| Input | Output | Observation |
|---|---|---|
| 2 4 128 0 100 128 200 50 129 255 64 |
0 0 0 255 0 255 255 0 |
Note that the value 128 became 0 (since \(128 \le 128\)) |
# your solutionTestSuite("EP01_07.py").run()✔️ EP01_07.cases already exists in casos/ 📋 7 case(s) loaded from casos/EP01_07.cases 💥 File EP01_07.py not found.