Update pages/LIFE_CYCLE_OF_MACHINE_LEARNING.py
Browse files
pages/LIFE_CYCLE_OF_MACHINE_LEARNING.py
CHANGED
@@ -227,9 +227,110 @@ Common Color Spaces:
|
|
227 |
if st.button("Operations Using OpenCV"):
|
228 |
st.session_state.page = "operations_using_opencv"
|
229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
# Navigation Button
|
231 |
if st.button("Back to Data Collection"):
|
232 |
-
st.session_state.page = "data_collection"
|
|
|
|
|
|
|
233 |
|
234 |
# ----------------- Semi-Structured Data Page -----------------
|
235 |
def semi_structured_data_page():
|
|
|
227 |
if st.button("Operations Using OpenCV"):
|
228 |
st.session_state.page = "operations_using_opencv"
|
229 |
|
230 |
+
# Navigation Button
|
231 |
+
if st.button("Back to Data Collection"):
|
232 |
+
st.session_state.page = "data_collection"
|
233 |
+
|
234 |
+
# ---------- OPERATIONS USING OPENCV --------------------------------
|
235 |
+
|
236 |
+
|
237 |
+
def operations_using_opencv():
|
238 |
+
# Header and description for cv2.imread
|
239 |
+
st.header("🗂️ Reading an Image with cv2.imread()")
|
240 |
+
st.markdown("""
|
241 |
+
**`cv2.imread()` - Read an Image**
|
242 |
+
|
243 |
+
**Purpose:** Load an image from a file and convert it to a NumPy array.
|
244 |
+
|
245 |
+
**Syntax:**
|
246 |
+
```python
|
247 |
+
image = cv2.imread(filename, flags)
|
248 |
+
```
|
249 |
+
|
250 |
+
**Common Flags:**
|
251 |
+
- `cv2.IMREAD_COLOR` (default, loads a color image).
|
252 |
+
- `cv2.IMREAD_GRAYSCALE` (loads the image in grayscale).
|
253 |
+
- `cv2.IMREAD_UNCHANGED` (loads the image as is, with alpha transparency if available).
|
254 |
+
|
255 |
+
**Return:**
|
256 |
+
- A NumPy array representing the image.
|
257 |
+
- Returns `None` if the image cannot be loaded.
|
258 |
+
|
259 |
+
**Example:**
|
260 |
+
```python
|
261 |
+
import cv2
|
262 |
+
image = cv2.imread('image.jpg', cv2.IMREAD_COLOR)
|
263 |
+
```
|
264 |
+
""")
|
265 |
+
|
266 |
+
# Header and description for cv2.imshow
|
267 |
+
st.header("🖼️ Displaying an Image with cv2.imshow()")
|
268 |
+
st.markdown("""
|
269 |
+
**`cv2.imshow()` - Display an Image**
|
270 |
+
|
271 |
+
**Purpose:** Show an image in a window.
|
272 |
+
|
273 |
+
**Syntax:**
|
274 |
+
```python
|
275 |
+
cv2.imshow(window_name, image)
|
276 |
+
```
|
277 |
+
|
278 |
+
**Requirements:**
|
279 |
+
- Call `cv2.waitKey()` to keep the window open until a key is pressed.
|
280 |
+
- Call `cv2.destroyAllWindows()` to close the window(s).
|
281 |
+
|
282 |
+
**Behavior:**
|
283 |
+
- Displays the image in a resizable window.
|
284 |
+
- The image must be a NumPy array.
|
285 |
+
|
286 |
+
**Example:**
|
287 |
+
```python
|
288 |
+
import cv2
|
289 |
+
cv2.imshow('Image Window', image)
|
290 |
+
cv2.waitKey(0) # Wait for a key press
|
291 |
+
cv2.destroyAllWindows() # Close the window
|
292 |
+
```
|
293 |
+
""")
|
294 |
+
|
295 |
+
# Header and description for cv2.imwrite
|
296 |
+
st.header("💾 Saving an Image with cv2.imwrite()")
|
297 |
+
st.markdown("""
|
298 |
+
**`cv2.imwrite()` - Write/Save an Image**
|
299 |
+
|
300 |
+
**Purpose:** Save an image to a file.
|
301 |
+
|
302 |
+
**Syntax:**
|
303 |
+
```python
|
304 |
+
cv2.imwrite(filename, image)
|
305 |
+
```
|
306 |
+
|
307 |
+
**File Format:**
|
308 |
+
Determined by the file extension (`.jpg`, `.png`, etc.).
|
309 |
+
|
310 |
+
**Return:**
|
311 |
+
- `True` if the image is saved successfully, `False` otherwise.
|
312 |
+
|
313 |
+
**Optional Parameters:**
|
314 |
+
- **JPEG Quality:** `cv2.IMWRITE_JPEG_QUALITY` (0 to 100, default is 95).
|
315 |
+
- **PNG Compression:** `cv2.IMWRITE_PNG_COMPRESSION` (0 to 9, default is 3).
|
316 |
+
|
317 |
+
**Example:**
|
318 |
+
```python
|
319 |
+
import cv2
|
320 |
+
cv2.imwrite('output.jpg', image)
|
321 |
+
```
|
322 |
+
""")
|
323 |
+
|
324 |
+
##Navigation Button
|
325 |
+
if st.button("Conversion of Images"):
|
326 |
+
st.session_state.page = "Conversion_of_Images"
|
327 |
+
|
328 |
# Navigation Button
|
329 |
if st.button("Back to Data Collection"):
|
330 |
+
st.session_state.page = "data_collection"
|
331 |
+
|
332 |
+
|
333 |
+
|
334 |
|
335 |
# ----------------- Semi-Structured Data Page -----------------
|
336 |
def semi_structured_data_page():
|