LakshmiHarika commited on
Commit
003fe2b
·
verified ·
1 Parent(s): 977c23b

Update pages/Data Collection.py

Browse files
Files changed (1) hide show
  1. pages/Data Collection.py +45 -6
pages/Data Collection.py CHANGED
@@ -559,10 +559,10 @@ elif st.session_state.current_page == "opencv_operations":
559
  import cv2
560
 
561
  # Read the image
562
- image = cv2.imread('path_to_image.jpg') # Replace 'path_to_image.jpg' with the image file path
563
 
564
  # Display the numerical matrix
565
- print(image) # This will print the image as an array of pixel values
566
  """, language="python")
567
 
568
  # Explanation for Grayscale Conversion
@@ -576,10 +576,10 @@ elif st.session_state.current_page == "opencv_operations":
576
  import cv2
577
 
578
  # Read the image in grayscale
579
- gray_image = cv2.imread('path_to_image.jpg', 0) # Replace 'path_to_image.jpg' with your image file path
580
 
581
  # Display the numerical matrix for the grayscale image
582
- print(gray_image) # This will print the 2D array representing pixel intensity
583
  """, language="python")
584
 
585
  # Displaying Images with OpenCV in Custom Color
@@ -615,9 +615,9 @@ elif st.session_state.current_page == "opencv_operations":
615
 
616
  st.code("""
617
  # imshow()
618
- cv2.imshow(window_name, image_array)
619
  # window_name: The title of the pop-up window
620
- # image_array: The image data (Array)
621
 
622
  # waitKey()
623
  cv2.waitKey(delay_in_milliseconds)
@@ -629,6 +629,45 @@ elif st.session_state.current_page == "opencv_operations":
629
  # This ensures all windows opened by imshow() are cleared from RAM
630
  """, language="python")
631
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
632
 
633
 
634
  elif st.session_state.current_page == "explore_audio":
 
559
  import cv2
560
 
561
  # Read the image
562
+ img = cv2.imread('path_to_image.jpg') # Replace 'path_to_image.jpg' with the image file path
563
 
564
  # Display the numerical matrix
565
+ print(img) # This will print the image as an array of pixel values
566
  """, language="python")
567
 
568
  # Explanation for Grayscale Conversion
 
576
  import cv2
577
 
578
  # Read the image in grayscale
579
+ gray_img = cv2.imread('path_to_image.jpg', 0) # Replace 'path_to_image.jpg' with your image file path
580
 
581
  # Display the numerical matrix for the grayscale image
582
+ print(gray_img) # This will print the 2D array representing pixel intensity
583
  """, language="python")
584
 
585
  # Displaying Images with OpenCV in Custom Color
 
615
 
616
  st.code("""
617
  # imshow()
618
+ cv2.imshow(window_name, img_array)
619
  # window_name: The title of the pop-up window
620
+ # img_array: The image data (Array)
621
 
622
  # waitKey()
623
  cv2.waitKey(delay_in_milliseconds)
 
629
  # This ensures all windows opened by imshow() are cleared from RAM
630
  """, language="python")
631
 
632
+ # Heading for Saving Images
633
+ st.markdown("""
634
+ <h3 style="color: #9400d3;">Saving an Image</h3>
635
+ """, unsafe_allow_html=True)
636
+
637
+ # About imwrite() function
638
+ st.write("""
639
+ To save an image file in OpenCV, we use the **imwrite()** function.
640
+ It converts the numerical array (image data) back into an image file format, such as `.jpg`, `.png`, or `.bmp`.
641
+ """)
642
+
643
+ # Code example
644
+ st.code("""
645
+ import cv2
646
+
647
+ # Example: Save an image
648
+ cv2.imwrite('saved_image.jpg', image_array) # 'saved_image.jpg' is the name of the output file
649
+ print("Image saved successfully!")
650
+ """, language="python")
651
+
652
+ st.write("""
653
+ In the next section, we'll take a closer look at **image creation and manipulation using OpenCV**. We'll discuss:
654
+ - **Creating different types of images** (black-and-white, grayscale, and RGB).
655
+ - **Splitting images** into individual channels.
656
+ - **Converting images** between various color spaces.
657
+
658
+ Curious to learn more?👇Click below to continue your journey with OpenCV! 🚀
659
+ """)
660
+
661
+ # Button to navigate to the next page
662
+ if st.button("Explore Image Creation and Manipulation"):
663
+ navigate_to("image_operations")
664
+
665
+ # Go Back Button
666
+ if st.button("Back to Previous Page"):
667
+ navigate_to("main")
668
+
669
+
670
+
671
 
672
 
673
  elif st.session_state.current_page == "explore_audio":