Spaces:
Sleeping
Sleeping
Update pages/Data Collection.py
Browse files- pages/Data Collection.py +18 -24
pages/Data Collection.py
CHANGED
|
@@ -315,34 +315,28 @@ elif st.session_state.current_page == "explore_images_video":
|
|
| 315 |
""", unsafe_allow_html=True)
|
| 316 |
|
| 317 |
|
| 318 |
-
#
|
| 319 |
-
|
| 320 |
-
grid = np.random.rand(height, width)
|
| 321 |
|
| 322 |
-
#
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
# Annotate the grid with pixel labels
|
| 327 |
-
for i in range(height):
|
| 328 |
-
for j in range(width):
|
| 329 |
-
ax.text(j, i, f'{grid[i, j]:.2f}', ha='center', va='center', fontsize=4) # Smaller fontsize
|
| 330 |
|
| 331 |
-
#
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
ax.set_ylabel("Height (Pixels)", fontsize=4) # Smaller label size
|
| 335 |
-
ax.set_xticks(range(width))
|
| 336 |
-
ax.set_yticks(range(height))
|
| 337 |
-
ax.set_xticklabels([f'Col {j+1}' for j in range(width)], fontsize=4) # Smaller label size
|
| 338 |
-
ax.set_yticklabels([f'Row {i+1}' for i in range(height)], fontsize=4) # Smaller label size
|
| 339 |
-
ax.grid(color='white', linestyle='-', linewidth=0.5) # Thinner grid lines
|
| 340 |
|
| 341 |
-
#
|
| 342 |
-
|
| 343 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 344 |
|
| 345 |
-
#
|
| 346 |
st.pyplot(fig)
|
| 347 |
|
| 348 |
# Section: What are Color Spaces?
|
|
|
|
| 315 |
""", unsafe_allow_html=True)
|
| 316 |
|
| 317 |
|
| 318 |
+
# Interactive Pixel Grid Section
|
| 319 |
+
st.subheader("Interactive Pixel Grid")
|
|
|
|
| 320 |
|
| 321 |
+
# User Input for Height and Width
|
| 322 |
+
height = st.number_input("Enter Image Height (pixels):", min_value=1, max_value=50, value=10, step=1)
|
| 323 |
+
width = st.number_input("Enter Image Width (pixels):", min_value=1, max_value=50, value=10, step=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 324 |
|
| 325 |
+
# Display Resolution
|
| 326 |
+
resolution = height * width
|
| 327 |
+
st.write(f"**Image Resolution**: {resolution} pixels")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 328 |
|
| 329 |
+
# Generate and Display Pixel Grid
|
| 330 |
+
st.write("**Pixel Grid Visualization:**")
|
| 331 |
+
grid = np.random.rand(int(height), int(width)) # Generate random grid values
|
| 332 |
+
fig, ax = plt.subplots()
|
| 333 |
+
cax = ax.imshow(grid, cmap="viridis") # Display grid with 'viridis' color map
|
| 334 |
+
plt.colorbar(cax, ax=ax) # Add color bar for context
|
| 335 |
+
ax.set_title("Pixel Grid")
|
| 336 |
+
ax.set_xlabel("Width")
|
| 337 |
+
ax.set_ylabel("Height")
|
| 338 |
|
| 339 |
+
# Render the Plot
|
| 340 |
st.pyplot(fig)
|
| 341 |
|
| 342 |
# Section: What are Color Spaces?
|