hari3485 commited on
Commit
69b5222
·
verified ·
1 Parent(s): fca0995

Update pages/video.py

Browse files
Files changed (1) hide show
  1. pages/video.py +79 -0
pages/video.py CHANGED
@@ -58,3 +58,82 @@ st.markdown("""
58
  img = cv2.imread("path/to/image")
59
  gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY
60
  """,unsafe_allow_html=True)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  img = cv2.imread("path/to/image")
59
  gray_img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY
60
  """,unsafe_allow_html=True)
61
+
62
+
63
+
64
+ from PIL import Image
65
+
66
+ # Set the title of the app
67
+
68
+ # Function to generate Black & White and Grayscale Images
69
+ def generate_bw_and_grayscale():
70
+ # Create Black & White binary image
71
+ bw_image = np.array([[0, 1, 0, 1],
72
+ [1, 0, 1, 0],
73
+ [0, 1, 0, 1],
74
+ [1, 0, 1, 0]])
75
+
76
+ # Create Grayscale image
77
+ grayscale_image = np.array([[0, 64, 128, 255],
78
+ [255, 128, 64, 0],
79
+ [0, 64, 128, 255],
80
+ [255, 128, 64, 0]])
81
+
82
+ # Plot and save the Black & White and Grayscale images
83
+ fig, axes = plt.subplots(1, 2, figsize=(10, 5))
84
+
85
+ # Black & White
86
+ axes[0].imshow(bw_image, cmap='binary', interpolation='nearest')
87
+ axes[0].set_title("Black & White Image")
88
+ axes[0].axis('off')
89
+
90
+ # Grayscale
91
+ axes[1].imshow(grayscale_image, cmap='gray', interpolation='nearest')
92
+ axes[1].set_title("Grayscale Image")
93
+ axes[1].axis('off')
94
+
95
+ plt.tight_layout()
96
+ return fig
97
+
98
+ # Function to generate RGB Color Space Images
99
+ def generate_rgb_color_space():
100
+ # Create RGB arrays
101
+ red = np.zeros((4, 4, 3), dtype=int)
102
+ green = np.zeros((4, 4, 3), dtype=int)
103
+ blue = np.zeros((4, 4, 3), dtype=int)
104
+
105
+ # Add intensity to respective channels
106
+ red[:, :, 0] = 255 # Red channel
107
+ green[:, :, 1] = 255 # Green channel
108
+ blue[:, :, 2] = 255 # Blue channel
109
+
110
+ # Plot RGB components
111
+ fig, axes = plt.subplots(1, 3, figsize=(15, 5))
112
+
113
+ # Red
114
+ axes[0].imshow(red)
115
+ axes[0].set_title("Red Component")
116
+ axes[0].axis('off')
117
+
118
+ # Green
119
+ axes[1].imshow(green)
120
+ axes[1].set_title("Green Component")
121
+ axes[1].axis('off')
122
+
123
+ # Blue
124
+ axes[2].imshow(blue)
125
+ axes[2].set_title("Blue Component")
126
+ axes[2].axis('off')
127
+
128
+ plt.tight_layout()
129
+ return fig
130
+
131
+ # Generate Black & White and Grayscale Images
132
+ st.subheader("Black & White and Grayscale Images")
133
+ bw_grayscale_fig = generate_bw_and_grayscale()
134
+ st.pyplot(bw_grayscale_fig)
135
+
136
+ # Generate RGB Color Space Images
137
+ st.subheader("RGB Color Space Visualization")
138
+ rgb_fig = generate_rgb_color_space()
139
+ st.pyplot(rgb_fig)