Spaces:
Sleeping
Sleeping
Update pages/Data Collection.py
Browse files- pages/Data Collection.py +11 -26
pages/Data Collection.py
CHANGED
|
@@ -573,6 +573,10 @@ def image_details_page():
|
|
| 573 |
- To represent coloured image we have to convert image in 3D array , Mixture of three 2D arrays is **RGB**.
|
| 574 |
- The value in each array ranges from R(0,255) ,G(0,255) ,B(0,255)
|
| 575 |
- By mixing different intensities of red, green, and blue,we can create over **16 million possible colors**.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 576 |
""")
|
| 577 |
|
| 578 |
st.image("https://huggingface.co/spaces/hari3485/DiveIntoML/resolve/main/Images/rgb.jpg")
|
|
@@ -758,28 +762,6 @@ def image_details_page():
|
|
| 758 |
cv2.waitKey(0)
|
| 759 |
cv2.destroyAllWindows()
|
| 760 |
""", language="python")
|
| 761 |
-
|
| 762 |
-
# Section 2: Merge colors
|
| 763 |
-
|
| 764 |
-
st.markdown("""
|
| 765 |
-
<h3 style="color: #e25822;">Combining Color Channels</h3>
|
| 766 |
-
""", unsafe_allow_html=True)
|
| 767 |
-
|
| 768 |
-
# About cv2.merge() function
|
| 769 |
-
st.write("""
|
| 770 |
-
To create a full color image from separate single-channel images (such as Red, Green, and Blue), the **cv2.merge()** function is used.
|
| 771 |
-
It combines individual color channels into a single, complete color image.
|
| 772 |
-
""")
|
| 773 |
-
|
| 774 |
-
# Syntax example for cv2.merge()
|
| 775 |
-
st.code("""
|
| 776 |
-
# Combining individual color channels (Blue, Green, Red)
|
| 777 |
-
merged_image = cv2.merge([blue_channel, green_channel, red_channel])
|
| 778 |
-
# blue_channel, green_channel, red_channel are individual images representing the Blue, Green, and Red color channels
|
| 779 |
-
""", language="python")
|
| 780 |
-
|
| 781 |
-
|
| 782 |
-
st.image("https://huggingface.co/spaces/hari3485/DiveIntoML/resolve/main/Images/merging%20BGR.jpg")
|
| 783 |
|
| 784 |
st.markdown("""
|
| 785 |
<h3 style="color: #9400d3;">Creating a BGR image</h3>
|
|
@@ -867,10 +849,10 @@ def image_details_page():
|
|
| 867 |
<h3 style="color: #9400d3;">Combining Channels </h3>
|
| 868 |
""", unsafe_allow_html=True)
|
| 869 |
|
|
|
|
| 870 |
st.write("""
|
| 871 |
-
|
| 872 |
-
|
| 873 |
-
For example, you can merge the individual Red, Green, and Blue channels back into a single RGB (or BGR in OpenCV) image.
|
| 874 |
""")
|
| 875 |
|
| 876 |
|
|
@@ -885,17 +867,20 @@ def image_details_page():
|
|
| 885 |
blue_channel = cv2.merge([b, zeros, zeros]) # The Blue channel has blue set to 255, and red and green to 0
|
| 886 |
green_channel = cv2.merge([zeros, g, zeros]) # The Green channel has green set to 255, and red and blue to 0
|
| 887 |
red_channel = cv2.merge([zeros, zeros, r]) # The Red channel has red set to 255, and green and blue to 0
|
|
|
|
| 888 |
|
| 889 |
# Show the separate color channels and the original image
|
| 890 |
cv2.imshow("Blue_channel", blue_channel)
|
| 891 |
cv2.imshow("Green_channel", green_channel)
|
| 892 |
cv2.imshow("Red_channel", red_channel)
|
| 893 |
-
cv2.imshow("
|
| 894 |
cv2.waitKey(0)
|
| 895 |
cv2.destroyAllWindows()
|
| 896 |
""", language="python")
|
| 897 |
|
| 898 |
|
|
|
|
|
|
|
| 899 |
|
| 900 |
|
| 901 |
|
|
|
|
| 573 |
- To represent coloured image we have to convert image in 3D array , Mixture of three 2D arrays is **RGB**.
|
| 574 |
- The value in each array ranges from R(0,255) ,G(0,255) ,B(0,255)
|
| 575 |
- By mixing different intensities of red, green, and blue,we can create over **16 million possible colors**.
|
| 576 |
+
- The **Red channel** has pixel values with red set to 255, and green and blue to 0.
|
| 577 |
+
- The **Green channel** has pixel values with green set to 255, and red and blue to 0.
|
| 578 |
+
- The **Blue channel** has pixel values with blue set to 255, and red and green to 0.
|
| 579 |
+
- When merged, these channels form a complete color image.
|
| 580 |
""")
|
| 581 |
|
| 582 |
st.image("https://huggingface.co/spaces/hari3485/DiveIntoML/resolve/main/Images/rgb.jpg")
|
|
|
|
| 762 |
cv2.waitKey(0)
|
| 763 |
cv2.destroyAllWindows()
|
| 764 |
""", language="python")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 765 |
|
| 766 |
st.markdown("""
|
| 767 |
<h3 style="color: #9400d3;">Creating a BGR image</h3>
|
|
|
|
| 849 |
<h3 style="color: #9400d3;">Combining Channels </h3>
|
| 850 |
""", unsafe_allow_html=True)
|
| 851 |
|
| 852 |
+
|
| 853 |
st.write("""
|
| 854 |
+
To create a full color image from separate single-channel images (such as Red, Green, and Blue), the **cv2.merge()** function is used.
|
| 855 |
+
It combines individual color channels into a single, complete color image.
|
|
|
|
| 856 |
""")
|
| 857 |
|
| 858 |
|
|
|
|
| 867 |
blue_channel = cv2.merge([b, zeros, zeros]) # The Blue channel has blue set to 255, and red and green to 0
|
| 868 |
green_channel = cv2.merge([zeros, g, zeros]) # The Green channel has green set to 255, and red and blue to 0
|
| 869 |
red_channel = cv2.merge([zeros, zeros, r]) # The Red channel has red set to 255, and green and blue to 0
|
| 870 |
+
|
| 871 |
|
| 872 |
# Show the separate color channels and the original image
|
| 873 |
cv2.imshow("Blue_channel", blue_channel)
|
| 874 |
cv2.imshow("Green_channel", green_channel)
|
| 875 |
cv2.imshow("Red_channel", red_channel)
|
| 876 |
+
cv2.imshow("merged_image", cv2.merge([blue_channel, green_channel, red_channel]))
|
| 877 |
cv2.waitKey(0)
|
| 878 |
cv2.destroyAllWindows()
|
| 879 |
""", language="python")
|
| 880 |
|
| 881 |
|
| 882 |
+
|
| 883 |
+
st.image("https://huggingface.co/spaces/hari3485/DiveIntoML/resolve/main/Images/merging%20BGR.jpg")
|
| 884 |
|
| 885 |
|
| 886 |
|