LakshmiHarika commited on
Commit
ef6fe9b
·
verified ·
1 Parent(s): befa3fd

Update pages/Data Collection.py

Browse files
Files changed (1) hide show
  1. pages/Data Collection.py +4 -4
pages/Data Collection.py CHANGED
@@ -415,21 +415,21 @@ elif st.session_state.current_page == "explore_images_video":
415
  Grayscale eliminates color information, focusing entirely on the intensity of light in an image. Each pixel has only one intensity value, making it a simpler and more compact representation compared to color images.
416
  """)
417
 
418
- # Section: Grayscale Representation
419
- st.subheader("Grayscale Representation")
420
-
421
  # Create grayscale gradient with labeled intensity values
422
  gradient = np.linspace(0, 255, 256) # Generate gradient values
423
  gradient = np.tile(gradient, (10, 1)) # Repeat the gradient to make it visually clear
424
 
425
  # Plot the gradient
426
- fig, ax = plt.subplots(figsize=(8, 2))
427
  ax.imshow(gradient, cmap='gray', aspect='auto')
428
  ax.set_xticks(np.linspace(0, 255, 11)) # Set ticks for every 25.5 (0, 25, ..., 255)
429
  ax.set_xticklabels([str(int(x)) for x in np.linspace(0, 255, 11)], fontsize=10, color='red') # Add labels in red
430
  ax.set_yticks([]) # Remove y-axis ticks
431
  ax.set_title("Grayscale Representation", fontsize=12)
432
 
 
 
 
433
  # Render the plot in Streamlit
434
  st.pyplot(fig)
435
 
 
415
  Grayscale eliminates color information, focusing entirely on the intensity of light in an image. Each pixel has only one intensity value, making it a simpler and more compact representation compared to color images.
416
  """)
417
 
 
 
 
418
  # Create grayscale gradient with labeled intensity values
419
  gradient = np.linspace(0, 255, 256) # Generate gradient values
420
  gradient = np.tile(gradient, (10, 1)) # Repeat the gradient to make it visually clear
421
 
422
  # Plot the gradient
423
+ fig, ax = plt.subplots(figsize=(8, 2), facecolor='none') # Set transparent facecolor
424
  ax.imshow(gradient, cmap='gray', aspect='auto')
425
  ax.set_xticks(np.linspace(0, 255, 11)) # Set ticks for every 25.5 (0, 25, ..., 255)
426
  ax.set_xticklabels([str(int(x)) for x in np.linspace(0, 255, 11)], fontsize=10, color='red') # Add labels in red
427
  ax.set_yticks([]) # Remove y-axis ticks
428
  ax.set_title("Grayscale Representation", fontsize=12)
429
 
430
+ # Save the figure with a transparent background
431
+ plt.savefig('grayscale_representation.png', transparent=True)
432
+
433
  # Render the plot in Streamlit
434
  st.pyplot(fig)
435