hari3485 commited on
Commit
a3e9a7d
·
verified ·
1 Parent(s): 3f6d752

Update pages/Data Collection.py

Browse files
Files changed (1) hide show
  1. pages/Data Collection.py +38 -2
pages/Data Collection.py CHANGED
@@ -836,7 +836,7 @@ def image_details_page():
836
 
837
  # Heading for the section
838
  st.markdown("""
839
- <h3 style="color: #9400d3;">Splitting and Recombining Color Channels</h3>
840
  """, unsafe_allow_html=True)
841
 
842
  # Code Example for Splitting and Merging Color Channels
@@ -855,13 +855,49 @@ def image_details_page():
855
  cv2.imshow("Blue_channel", blue_channel)
856
  cv2.imshow("Green_channel", green_channel)
857
  cv2.imshow("Red_channel", red_channel)
858
- cv2.imshow("Original_img", cv2.merge([b, g, r]))
859
  cv2.waitKey(0)
860
  cv2.destroyAllWindows()
861
  """, language="python")
862
 
863
  st.image("https://huggingface.co/spaces/hari3485/DiveIntoML/resolve/main/Images/BGR%20to%20Split.jpg")
864
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
865
  # Title of the app
866
  st.markdown("""
867
  <h3 style="color: #9400d3;">Converting colour spaces</h3>
 
836
 
837
  # Heading for the section
838
  st.markdown("""
839
+ <h3 style="color: #9400d3;">Splitting Channels </h3>
840
  """, unsafe_allow_html=True)
841
 
842
  # Code Example for Splitting and Merging Color Channels
 
855
  cv2.imshow("Blue_channel", blue_channel)
856
  cv2.imshow("Green_channel", green_channel)
857
  cv2.imshow("Red_channel", red_channel)
 
858
  cv2.waitKey(0)
859
  cv2.destroyAllWindows()
860
  """, language="python")
861
 
862
  st.image("https://huggingface.co/spaces/hari3485/DiveIntoML/resolve/main/Images/BGR%20to%20Split.jpg")
863
 
864
+ st.markdown("""
865
+ <h3 style="color: #9400d3;">Combining Channels </h3>
866
+ """, unsafe_allow_html=True)
867
+
868
+ st.write("""
869
+ The `cv2.merge()` function in OpenCV is used to combine separate single-channel arrays (such as the individual Red, Green, and Blue channels) into a single multi-channel image.
870
+ This is particularly useful when you have split an image into its component channels and then want to reassemble them into the original format.
871
+ For example, you can merge the individual Red, Green, and Blue channels back into a single RGB (or BGR in OpenCV) image.
872
+ """)
873
+
874
+
875
+ # Code Example for Splitting and Merging Color Channels
876
+ st.code("""
877
+ img = cv2.imread("path of the image") # Load the image
878
+
879
+ b, g, r = cv2.split(img) # Separate the image into Blue, Green, and Red channels
880
+
881
+ zeros = np.zeros(img.shape[:-1], dtype=np.uint8) # Create a blank array for the empty channels
882
+
883
+ blue_channel = cv2.merge([b, zeros, zeros]) # The Blue channel has blue set to 255, and red and green to 0
884
+ green_channel = cv2.merge([zeros, g, zeros]) # The Green channel has green set to 255, and red and blue to 0
885
+ red_channel = cv2.merge([zeros, zeros, r]) # The Red channel has red set to 255, and green and blue to 0
886
+
887
+ # Show the separate color channels and the original image
888
+ cv2.imshow("Blue_channel", blue_channel)
889
+ cv2.imshow("Green_channel", green_channel)
890
+ cv2.imshow("Red_channel", red_channel)
891
+ cv2.imshow("Original_img", cv2.merge([b, g, r]))
892
+ cv2.waitKey(0)
893
+ cv2.destroyAllWindows()
894
+ """, language="python")
895
+
896
+
897
+
898
+
899
+
900
+
901
  # Title of the app
902
  st.markdown("""
903
  <h3 style="color: #9400d3;">Converting colour spaces</h3>