Spaces:
Sleeping
Sleeping
Update pages/7_Unstructured_data.py
Browse files- pages/7_Unstructured_data.py +54 -0
pages/7_Unstructured_data.py
CHANGED
|
@@ -333,15 +333,69 @@ if file_type == "IMAGE":
|
|
| 333 |
- **Splitting Channels**: Use `cv2.split()` to separate the image into individual channels (B, G, R).
|
| 334 |
|
| 335 |
```python
|
|
|
|
| 336 |
blue, green, red = cv2.split(image)
|
| 337 |
```
|
| 338 |
- **Merging Channels**: Combine individual channels back into a single image using `cv2.merge()`.
|
| 339 |
|
| 340 |
```python
|
|
|
|
| 341 |
merged_image = cv2.merge((blue, green, red))
|
| 342 |
```
|
| 343 |
""", unsafe_allow_html=True)
|
| 344 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 345 |
|
| 346 |
|
| 347 |
|
|
|
|
| 333 |
- **Splitting Channels**: Use `cv2.split()` to separate the image into individual channels (B, G, R).
|
| 334 |
|
| 335 |
```python
|
| 336 |
+
import cv2
|
| 337 |
blue, green, red = cv2.split(image)
|
| 338 |
```
|
| 339 |
- **Merging Channels**: Combine individual channels back into a single image using `cv2.merge()`.
|
| 340 |
|
| 341 |
```python
|
| 342 |
+
import cv2
|
| 343 |
merged_image = cv2.merge((blue, green, red))
|
| 344 |
```
|
| 345 |
""", unsafe_allow_html=True)
|
| 346 |
|
| 347 |
+
st.markdown("""
|
| 348 |
+
|
| 349 |
+
**1. Read the image**
|
| 350 |
+
```python
|
| 351 |
+
image = cv2.imread('input_image.jpg')
|
| 352 |
+
if image is None:
|
| 353 |
+
print("Error: Image not found")
|
| 354 |
+
exit()
|
| 355 |
+
```
|
| 356 |
+
|
| 357 |
+
**2. Convert RGB to Grayscale**
|
| 358 |
+
```python
|
| 359 |
+
gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
| 360 |
+
```
|
| 361 |
+
|
| 362 |
+
**3. Convert Grayscale back to RGB**
|
| 363 |
+
```python
|
| 364 |
+
rgb_image = cv2.cvtColor(gray_image, cv2.COLOR_GRAY2BGR)
|
| 365 |
+
```
|
| 366 |
+
|
| 367 |
+
**4. Split channels (B, G, R)**
|
| 368 |
+
```python
|
| 369 |
+
blue, green, red = cv2.split(image)
|
| 370 |
+
```
|
| 371 |
+
|
| 372 |
+
**5. Merge channels back**
|
| 373 |
+
```python
|
| 374 |
+
merged_image = cv2.merge((blue, green, red))
|
| 375 |
+
```
|
| 376 |
+
|
| 377 |
+
**6. Save the processed image**
|
| 378 |
+
```python
|
| 379 |
+
cv2.imwrite('processed_image.jpg', merged_image)
|
| 380 |
+
```
|
| 381 |
+
""", unsafe_allow_html=True)
|
| 382 |
+
|
| 383 |
+
st.markdown("""
|
| 384 |
+
- Explanation :
|
| 385 |
+
|
| 386 |
+
- **Step 1**: Read the image using `cv2.imread()`. Terminates if the image file is not found.
|
| 387 |
+
|
| 388 |
+
- **Step 2**: Convert the image to Grayscale using `cv2.cvtColor()`. This simplifies the image to a single channel.
|
| 389 |
+
|
| 390 |
+
- **Step 3**: Convert the Grayscale image back to RGB to enable further processing.
|
| 391 |
+
|
| 392 |
+
- **Step 4**: Use `cv2.split()` to separate the image into individual color channels.
|
| 393 |
+
|
| 394 |
+
- **Step 5**: Combine the channels back into a single image using `cv2.merge()`.
|
| 395 |
+
|
| 396 |
+
- **Step 6**: Save the final loaded image with `cv2.imwrite()`.
|
| 397 |
+
""", unsafe_allow_html=True)
|
| 398 |
+
|
| 399 |
|
| 400 |
|
| 401 |
|