Spaces:
Sleeping
Sleeping
Update pages/Data Collection.py
Browse files- pages/Data Collection.py +50 -1
pages/Data Collection.py
CHANGED
|
@@ -748,8 +748,57 @@ elif st.session_state.current_page == "image_operations":
|
|
| 748 |
cv2.waitKey(0) # 0 means infinite delay
|
| 749 |
cv2.destroyAllWindows()
|
| 750 |
""", language="python")
|
| 751 |
-
|
| 752 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 753 |
|
| 754 |
|
| 755 |
elif st.session_state.current_page == "explore_audio":
|
|
|
|
| 748 |
cv2.waitKey(0) # 0 means infinite delay
|
| 749 |
cv2.destroyAllWindows()
|
| 750 |
""", language="python")
|
|
|
|
| 751 |
|
| 752 |
+
# Heading for cv2.merge() function
|
| 753 |
+
st.markdown("""
|
| 754 |
+
<h3 style="color: #9400d3;">Merging Color Channels</h3>
|
| 755 |
+
""", unsafe_allow_html=True)
|
| 756 |
+
|
| 757 |
+
# About cv2.merge() function
|
| 758 |
+
st.write("""
|
| 759 |
+
To combine multiple single-channel images (like Red, Green, and Blue) into a single multi-channel image, we use the **cv2.merge()** function.
|
| 760 |
+
This function merges individual color channels into a complete color image.
|
| 761 |
+
""")
|
| 762 |
+
|
| 763 |
+
# Syntax example
|
| 764 |
+
cv2.merge((blue_channel, green_channel, red_channel)) # blue_channel, green_channel, red_channel are Single-channel images representing the individual color channels(Blue, Green, Red)
|
| 765 |
+
""", language="python")
|
| 766 |
+
|
| 767 |
+
# Heading for Creating RGB Image
|
| 768 |
+
st.markdown("""
|
| 769 |
+
<h3 style="color: #9400d3;">Creating a Colored RGB Image</h3>
|
| 770 |
+
""", unsafe_allow_html=True)
|
| 771 |
+
|
| 772 |
+
# Explanation
|
| 773 |
+
st.write("""
|
| 774 |
+
To create a colored image, we use individual color channels (Red, Green, Blue) and merge them using `cv2.merge()`.
|
| 775 |
+
In this example:
|
| 776 |
+
- The **Blue channel** is filled with 255 (full intensity).
|
| 777 |
+
- The **Green channel** is set to 0 (no intensity).
|
| 778 |
+
- The **Red channel** is also set to 0 (no intensity).
|
| 779 |
+
|
| 780 |
+
The channels are then merged into a single RGB image, which is displayed using OpenCV.
|
| 781 |
+
""")
|
| 782 |
+
|
| 783 |
+
# Code example
|
| 784 |
+
st.code("""
|
| 785 |
+
# Create individual color channels
|
| 786 |
+
b = np.full((300, 300), 255, dtype=np.uint8) # Blue channel
|
| 787 |
+
g = np.zeros((300, 300), dtype=np.uint8) # Green channel
|
| 788 |
+
r = np.zeros((300, 300), dtype=np.uint8) # Red channel
|
| 789 |
+
|
| 790 |
+
# Merge the color channels to create RGB images
|
| 791 |
+
b_img = cv2.merge([b, g, r]) # Blue image
|
| 792 |
+
g_img = cv2.merge([g, b, r]) # Green image
|
| 793 |
+
r_img = cv2.merge([r, g, b]) # Red image
|
| 794 |
+
|
| 795 |
+
# Display the images
|
| 796 |
+
cv2.imshow("Blue", b_img)
|
| 797 |
+
cv2.imshow("Green", g_img)
|
| 798 |
+
cv2.imshow("Red", r_img)
|
| 799 |
+
cv2.waitKey(0)
|
| 800 |
+
cv2.destroyAllWindows()
|
| 801 |
+
""", language="python")
|
| 802 |
|
| 803 |
|
| 804 |
elif st.session_state.current_page == "explore_audio":
|