LakshmiHarika commited on
Commit
4e517d4
·
verified ·
1 Parent(s): d15534b

Update pages/Data Collection.py

Browse files
Files changed (1) hide show
  1. 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
- # Visualization for Grid-Like Structure
319
- height, width = 3,3
320
- grid = np.random.rand(height, width)
321
 
322
- # Adjust the figure size to make the plot very small
323
- fig, ax = plt.subplots(figsize=(2,2)) # Even smaller figure size
324
- cax = ax.imshow(grid, cmap='viridis', interpolation='nearest')
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
- # Set axis labels and title
332
- ax.set_title("Image as a Grid-Like Structure", fontsize=5) # Smaller title size
333
- ax.set_xlabel("Width (Pixels)", fontsize=4) # Smaller label size
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
- # Color bar setup without fontsize argument
342
- cbar = fig.colorbar(cax, ax=ax, orientation='vertical')
343
- cbar.ax.tick_params(labelsize=4) # Adjust the font size of the color bar
 
 
 
 
 
 
344
 
345
- # Display the plot
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?