Spaces:
Sleeping
Sleeping
Update pages/Data Collection.py
Browse files- pages/Data Collection.py +46 -1
pages/Data Collection.py
CHANGED
|
@@ -760,7 +760,7 @@ elif st.session_state.current_page == "image_operations":
|
|
| 760 |
st.code("""
|
| 761 |
# Merging individual color channels (Blue, Green, Red)
|
| 762 |
merged_image = cv2.merge([blue_channel, green_channel, red_channel])
|
| 763 |
-
# blue_channel,
|
| 764 |
""", language="python")
|
| 765 |
|
| 766 |
# Heading for Creating RGB Image
|
|
@@ -781,6 +781,7 @@ elif st.session_state.current_page == "image_operations":
|
|
| 781 |
|
| 782 |
# Code example
|
| 783 |
st.code("""
|
|
|
|
| 784 |
# Create individual color channels
|
| 785 |
b = np.full((300, 300), 255, dtype=np.uint8) # Blue channel
|
| 786 |
g = np.zeros((300, 300), dtype=np.uint8) # Green channel
|
|
@@ -799,6 +800,50 @@ elif st.session_state.current_page == "image_operations":
|
|
| 799 |
cv2.destroyAllWindows() # Close all OpenCV windows
|
| 800 |
""", language="python")
|
| 801 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 802 |
|
| 803 |
elif st.session_state.current_page == "explore_audio":
|
| 804 |
st.markdown("""
|
|
|
|
| 760 |
st.code("""
|
| 761 |
# Merging individual color channels (Blue, Green, Red)
|
| 762 |
merged_image = cv2.merge([blue_channel, green_channel, red_channel])
|
| 763 |
+
# blue_channel,green_channel,red_channel are single-channel images representing individual color channels(Blue, Green, Red)
|
| 764 |
""", language="python")
|
| 765 |
|
| 766 |
# Heading for Creating RGB Image
|
|
|
|
| 781 |
|
| 782 |
# Code example
|
| 783 |
st.code("""
|
| 784 |
+
|
| 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
|
|
|
|
| 800 |
cv2.destroyAllWindows() # Close all OpenCV windows
|
| 801 |
""", language="python")
|
| 802 |
|
| 803 |
+
# Heading for Splitting Channels
|
| 804 |
+
st.markdown("""
|
| 805 |
+
<h3 style="color: #9400d3;">Splitting Channels</h3>
|
| 806 |
+
""", unsafe_allow_html=True)
|
| 807 |
+
|
| 808 |
+
# About cv2.split() function
|
| 809 |
+
st.write("""
|
| 810 |
+
The `cv2.split()` function in OpenCV is used to divide an image into its individual color channels.
|
| 811 |
+
It creates separate single-channel arrays for each color, allowing you to work with them independently.
|
| 812 |
+
For example, it can split an RGB image into its Red, Green, and Blue channels.
|
| 813 |
+
""")
|
| 814 |
+
|
| 815 |
+
# Syntax for cv2.split() function
|
| 816 |
+
st.code("""
|
| 817 |
+
# Syntax for cv2.split()
|
| 818 |
+
channels = cv2.split(image)
|
| 819 |
+
# image: The input image (e.g., an RGB image).
|
| 820 |
+
# channels: A list of single-channel images (e.g., Blue, Green, Red).
|
| 821 |
+
""", language="python")
|
| 822 |
+
|
| 823 |
+
# Heading for the section
|
| 824 |
+
st.markdown("""
|
| 825 |
+
<h3 style="color: #9400d3;">Splitting and Merging Color Channels</h3>
|
| 826 |
+
""", unsafe_allow_html=True)
|
| 827 |
+
|
| 828 |
+
# Code Example for Splitting and Merging Color Channels
|
| 829 |
+
st.code("""
|
| 830 |
+
img = cv2.imread(r"P:\\BSG(P)\\7b144ce3dff5652ff59f2eb694eba472.jpg") # Read the image
|
| 831 |
+
|
| 832 |
+
b, g, r = cv2.split(img) # Split the image into Blue, Green, and Red channels
|
| 833 |
+
|
| 834 |
+
zeros = np.zeros(img.shape[:-1], dtype=np.uint8) # Create a zeros array to hold the empty channels
|
| 835 |
+
|
| 836 |
+
blue_channel = cv2.merge([b, zeros, zeros]) # Merge the Blue channel with zeros for Green and Red
|
| 837 |
+
green_channel = cv2.merge([zeros, g, zeros]) # Merge the Green channel with zeros for Blue and Red
|
| 838 |
+
red_channel = cv2.merge([zeros, zeros, r]) # Merge the Red channel with zeros for Blue and Green
|
| 839 |
+
|
| 840 |
+
# Display the individual color channels and the original image
|
| 841 |
+
cv2.imshow("Blue_channel", blue_channel)
|
| 842 |
+
cv2.imshow("Green_channel", green_channel)
|
| 843 |
+
cv2.imshow("Red_channel", red_channel)
|
| 844 |
+
cv2.imshow("Original_img", cv2.merge([b, g, r]))
|
| 845 |
+
cv2.waitKey(0)
|
| 846 |
+
cv2.destroyAllWindows()
|
| 847 |
|
| 848 |
elif st.session_state.current_page == "explore_audio":
|
| 849 |
st.markdown("""
|