Raykarr commited on
Commit
6542d1c
·
verified ·
1 Parent(s): d46815b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -30
app.py CHANGED
@@ -210,33 +210,3 @@ st.markdown("""
210
 
211
  **Thank you for exploring this demonstration!**
212
  """)
213
-
214
- # -----------------------------------------------------------------
215
- # How the Code Works - Explanation
216
- # -----------------------------------------------------------------
217
- st.header("How This Code Works")
218
- st.markdown("""
219
- 1. **Utility Functions**
220
- - **`generate_colorful_image`**: Creates a synthetic image with a customizable proportion of blue pixels. This simulates different real-world scenarios, such as varying amounts of a brand color on packaging.
221
- - **`simple_threshold_blue`**: Uses basic HSV thresholding to identify blue pixels. Provides a quick, broad detection method.
222
- - **`advanced_threshold_blue`**: Combines multiple ranges for different shades of blue and applies morphological operations for noise reduction, giving more robust results.
223
- - **`plot_color_histogram`**: Plots separate color channel (B, G, R) histograms to visualize the distribution of pixel intensities.
224
-
225
- 2. **Streamlit Layout**
226
- - **`Sidebar`**: Controls to adjust the fraction of blueish pixels and the image size. A button to generate a new random image is also included.
227
- - **`Main Page`**:
228
- - Displays the generated image and its color histogram side by side.
229
- - Shows the simple vs. advanced detection masks with the calculated percentage of blue.
230
- - Progress bars indicate the proportion of blue visually.
231
-
232
- 3. **Industry 4.0 Context**
233
- - By integrating this approach with IoT devices, large-scale manufacturing lines can automate color checks. The masks and percentage calculations serve as a foundation for real-time QA alerts, data logging, and future analytics.
234
-
235
- 4. **Execution Flow**
236
- 1. When the user clicks "`Generate New Random Image`," it calls `generate_colorful_image()` to create a fresh synthetic image.
237
- 2. The image is converted to RGB for display. Meanwhile, `plot_color_histogram()` renders a histogram for deeper insight into color distribution.
238
- 3. The **`simple_threshold_blue`** and **`advanced_threshold_blue`** functions each produce their own masks and calculations, displayed in the main interface.
239
- 4. By comparing the results of both methods, users can see the differences in detection accuracy and how morphological operations can refine the result.
240
-
241
- This cohesive setup ensures a **user-friendly**, **real-time** demonstration of how color segmentation can be applied to industrial use cases—especially relevant for ITC PSPD's commitments to **quality** and **innovation**.
242
- """)
 
210
 
211
  **Thank you for exploring this demonstration!**
212
  """)