SHARE
TWEET

Untitled

a guest Sep 22nd, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #This program loads an image, displays it, and then creates, displays
  2.  
  3. #and saves a new image that has only the green channel displayed.
  4.  
  5.  
  6. #Import the packages for images and arrays:
  7.  
  8. import matplotlib.pyplot as plt
  9.  
  10.  
  11. inputFile = input("Enter name of the input file: ")
  12.  
  13. outputFile = input("Enter name of the output file: ")
  14.  
  15.  
  16. img = plt.imread(inputFile)  
  17. #Read in image from csBridge.png
  18.  
  19.  
  20. img2 = img.copy()        
  21. #make a copy of our image
  22. img2[:,:,0] = 0          
  23. #Set the green channel to 0
  24. img2[:,:,2] = 0          
  25. #Set the blue channel to 0
  26.  
  27.  
  28. plt.imsave(outputFile, img2)  
  29. #Save the image we created to the file: reds.png
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top