Spaces:
Sleeping
Sleeping
Update pages/Data Collection.py
Browse files- pages/Data Collection.py +27 -53
pages/Data Collection.py
CHANGED
|
@@ -434,75 +434,49 @@ elif st.session_state.current_page == "explore_images_video":
|
|
| 434 |
st.pyplot(fig)
|
| 435 |
|
| 436 |
st.image(
|
| 437 |
-
"https://huggingface.co/spaces/LakshmiHarika/MachineLearning/resolve/main/
|
| 438 |
caption="Gray Scale Color Space.",
|
| 439 |
use_container_width=True)
|
| 440 |
|
| 441 |
# Section: What is RGB Color Space?
|
| 442 |
st.subheader("What is RGB Color Space?")
|
| 443 |
st.write("""
|
| 444 |
-
RGB color space represents an image using three primary colors: **Red**, **Green**, and **Blue**.
|
| 445 |
|
| 446 |
-
A colored image in the RGB color space is split into
|
| 447 |
-
- **Red Channel
|
| 448 |
-
- **Green Channel
|
| 449 |
-
- **Blue Channel
|
| 450 |
|
| 451 |
-
Each
|
| 452 |
-
- Each pixel contains a value ranging from **0** (no intensity) to **255** (maximum intensity) for that color.
|
| 453 |
|
| 454 |
-
By combining
|
| 455 |
-
For example:
|
| 456 |
- **(255, 0, 0)** represents pure **Red**.
|
| 457 |
- **(0, 255, 0)** represents pure **Green**.
|
| 458 |
- **(0, 0, 255)** represents pure **Blue**.
|
| 459 |
-
- **(255, 255, 255)** represents **White
|
| 460 |
-
- **(0, 0, 0)** represents **Black
|
|
|
|
| 461 |
|
| 462 |
-
|
| 463 |
-
|
| 464 |
-
|
| 465 |
-
|
| 466 |
-
# Subheader for the section
|
| 467 |
-
st.subheader("Visualization of RGB Channels")
|
| 468 |
-
|
| 469 |
-
# File uploader for the user to upload an image
|
| 470 |
-
uploaded_file = st.file_uploader("Upload an Image (JPG or PNG):", type=["jpg", "png"])
|
| 471 |
-
|
| 472 |
-
if uploaded_file is not None:
|
| 473 |
-
# Open the uploaded image
|
| 474 |
-
img = Image.open(uploaded_file)
|
| 475 |
-
img_array = np.array(img)
|
| 476 |
-
|
| 477 |
-
# Ensure the image has three channels (for RGB visualization)
|
| 478 |
-
if img_array.shape[-1] == 3:
|
| 479 |
-
# Split the image into its RGB channels
|
| 480 |
-
red_channel = img_array[:, :, 0]
|
| 481 |
-
green_channel = img_array[:, :, 1]
|
| 482 |
-
blue_channel = img_array[:, :, 2]
|
| 483 |
-
|
| 484 |
-
# Plot the original image and the three channels
|
| 485 |
-
fig, ax = plt.subplots(1, 4, figsize=(15, 5))
|
| 486 |
-
ax[0].imshow(img)
|
| 487 |
-
ax[0].set_title("Original Image")
|
| 488 |
-
ax[1].imshow(red_channel, cmap="Reds")
|
| 489 |
-
ax[1].set_title("Red Channel")
|
| 490 |
-
ax[2].imshow(green_channel, cmap="Greens")
|
| 491 |
-
ax[2].set_title("Green Channel")
|
| 492 |
-
ax[3].imshow(blue_channel, cmap="Blues")
|
| 493 |
-
ax[3].set_title("Blue Channel")
|
| 494 |
-
|
| 495 |
-
# Remove axis labels and ticks
|
| 496 |
-
for a in ax:
|
| 497 |
-
a.axis("off")
|
| 498 |
-
|
| 499 |
-
# Render the plot in Streamlit
|
| 500 |
-
st.pyplot(fig)
|
| 501 |
-
else:
|
| 502 |
-
st.error("The uploaded image does not have 3 color channels (RGB). Please upload an RGB image.")
|
| 503 |
|
|
|
|
| 504 |
|
|
|
|
|
|
|
| 505 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 506 |
|
| 507 |
# Go Back Button
|
| 508 |
if st.button("Go Back"):
|
|
|
|
| 434 |
st.pyplot(fig)
|
| 435 |
|
| 436 |
st.image(
|
| 437 |
+
"https://huggingface.co/spaces/LakshmiHarika/MachineLearning/resolve/main/Images/gray_scale.jpg",
|
| 438 |
caption="Gray Scale Color Space.",
|
| 439 |
use_container_width=True)
|
| 440 |
|
| 441 |
# Section: What is RGB Color Space?
|
| 442 |
st.subheader("What is RGB Color Space?")
|
| 443 |
st.write("""
|
| 444 |
+
RGB color space represents an image using three primary colors: **Red**, **Green**, and **Blue**. These colors form the basis of digital images and can be combined in different intensities to create a wide range of colors.
|
| 445 |
|
| 446 |
+
A colored image in the RGB color space is split into three separate channels:
|
| 447 |
+
- **Red Channel**: Contains the intensity of the red color at each pixel.
|
| 448 |
+
- **Green Channel**: Contains the intensity of the green color at each pixel.
|
| 449 |
+
- **Blue Channel**: Contains the intensity of the blue color at each pixel.
|
| 450 |
|
| 451 |
+
Each of these channels is represented as a **2D array**, where:
|
| 452 |
+
- Each pixel in the 2D array contains a value ranging from **0** (no intensity) to **255** (maximum intensity) for that color.
|
| 453 |
|
| 454 |
+
By combining the three channels, a wide range of colors can be formed. For example:
|
|
|
|
| 455 |
- **(255, 0, 0)** represents pure **Red**.
|
| 456 |
- **(0, 255, 0)** represents pure **Green**.
|
| 457 |
- **(0, 0, 255)** represents pure **Blue**.
|
| 458 |
+
- **(255, 255, 255)** represents **White**, where all channels are at maximum intensity.
|
| 459 |
+
- **(0, 0, 0)** represents **Black**, where all channels have no intensity.
|
| 460 |
+
- Combining colors, such as **Red + Green = Yellow**, **Green + Blue = Cyan**, and **Blue + Red = Magenta**, creates even more colors. By adjusting the intensity of each channel, millions of unique colors can be generated.
|
| 461 |
|
| 462 |
+
Computers interpret RGB images as **3D arrays**:
|
| 463 |
+
- The **width** and **height** of the 3D array correspond to the dimensions of the image.
|
| 464 |
+
- The **depth** of the 3D array corresponds to the number of color channels, which is three in the case of RGB (Red, Green, and Blue).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 465 |
|
| 466 |
+
In an RGB image, each color channel is represented by its own **2D array**, and these three 2D arrays are stacked together to form the **3D array**. This means that an RGB image is essentially a combination of three 2D arrays: one for red, one for green, and one for blue.
|
| 467 |
|
| 468 |
+
Altogether, these three channels work together to form a complete color image. The 3D array structure not only makes it easier for computers to process images but also allows for advanced image manipulation and analysis. This is why RGB is the most commonly used color space in digital imaging, particularly for devices that emit light, such as monitors, TVs, and cameras.
|
| 469 |
+
""")
|
| 470 |
|
| 471 |
+
st.image(
|
| 472 |
+
"https://huggingface.co/spaces/LakshmiHarika/MachineLearning/resolve/main/Images/rgb_1.jpg",
|
| 473 |
+
use_container_width=True)
|
| 474 |
+
st.image(
|
| 475 |
+
"https://huggingface.co/spaces/LakshmiHarika/MachineLearning/resolve/main/Images/rgb_2.jpg",
|
| 476 |
+
use_container_width=True)
|
| 477 |
+
st.image(
|
| 478 |
+
"https://huggingface.co/spaces/LakshmiHarika/MachineLearning/resolve/main/Images/rgb_3.jpg",
|
| 479 |
+
use_container_width=True)
|
| 480 |
|
| 481 |
# Go Back Button
|
| 482 |
if st.button("Go Back"):
|