Spaces:
Sleeping
Sleeping
Update pages/Data Collection.py
Browse files- pages/Data Collection.py +44 -0
pages/Data Collection.py
CHANGED
|
@@ -704,7 +704,51 @@ elif st.session_state.current_page == "image_operations":
|
|
| 704 |
In this section, we’ll learn how to create different types of images, split them into their color channels, and convert between various color spaces to manipulate images more effectively.
|
| 705 |
""")
|
| 706 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 707 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 708 |
|
| 709 |
|
| 710 |
|
|
|
|
| 704 |
In this section, we’ll learn how to create different types of images, split them into their color channels, and convert between various color spaces to manipulate images more effectively.
|
| 705 |
""")
|
| 706 |
|
| 707 |
+
# Heading for Creating Black and White Image
|
| 708 |
+
st.markdown("""
|
| 709 |
+
<h3 style="color: #9400d3;">Creating a Black and White Image</h3>
|
| 710 |
+
""", unsafe_allow_html=True)
|
| 711 |
+
|
| 712 |
+
# Explanation
|
| 713 |
+
st.write("""
|
| 714 |
+
In OpenCV, black and white images are created by filling a matrix with pixel values:
|
| 715 |
+
- **Black image**: All pixel values are set to 0.
|
| 716 |
+
- **White image**: All pixel values are set to 255.
|
| 717 |
+
""")
|
| 718 |
+
|
| 719 |
+
# Code example
|
| 720 |
+
st.code("""
|
| 721 |
+
white_img = np.full((500, 500), 255, dtype=np.uint8) # Create a white image
|
| 722 |
+
|
| 723 |
+
black_img = np.zeros((500, 500), dtype=np.uint8) # Create a black image
|
| 724 |
|
| 725 |
+
# Display the images
|
| 726 |
+
cv2.imshow("White", white_img)
|
| 727 |
+
cv2.imshow("Black", black_img)
|
| 728 |
+
cv2.waitKey(0) # 0 means infinite delay
|
| 729 |
+
cv2.destroyAllWindows()
|
| 730 |
+
""", language="python")
|
| 731 |
+
|
| 732 |
+
# Heading for Creating Grayscale Image
|
| 733 |
+
st.markdown("""
|
| 734 |
+
<h3 style="color: #9400d3;">Creating a Grayscale Image</h3>
|
| 735 |
+
""", unsafe_allow_html=True)
|
| 736 |
+
|
| 737 |
+
# Explanation
|
| 738 |
+
st.write("""
|
| 739 |
+
In OpenCV, grayscale images are created by filling a matrix with pixel intensity values. The values range from 0 (black) to 255 (white).
|
| 740 |
+
""")
|
| 741 |
+
|
| 742 |
+
# Code example
|
| 743 |
+
st.code("""
|
| 744 |
+
gray_img = np.full((500, 500), 127, dtype=np.uint8) # Create a grayscale image (127 represents medium gray)
|
| 745 |
+
|
| 746 |
+
# Display the grayscale image
|
| 747 |
+
cv2.imshow("Grayscale", gray_img)
|
| 748 |
+
cv2.waitKey(0) # 0 means infinite delay
|
| 749 |
+
cv2.destroyAllWindows()
|
| 750 |
+
""", language="python")
|
| 751 |
+
|
| 752 |
|
| 753 |
|
| 754 |
|