title: How to convert a RGB image (3 channel) to grayscale (1 channel) and save it?
body: <p>Working with a deep learning project and I have a lot of images, that don't need to have colors. I saved them doing:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  
  plt.imsave('image.png', image, format='png', cmap='gray')
  </code></pre>
  
  <p>However later when I checked the shape of the image the result is:</p>
  
  <pre><code>import cv2
  img_rgb = cv2.imread('image.png')
  print(img_rgb.shape)
  (196,256,3)
  </code></pre>
  
  <p>So even though the image I view is in grayscale, I still have 3 color channels. I realized I had to do some algebric operations in order to convert those 3 channels into 1 single channel.</p>
  
  <p>I have tried the methods described on the thread "<a href="https://stackoverflow.com/questions/12201577/how-can-i-convert-an-rgb-image-into-grayscale-in-python">How can I convert an RGB image into grayscale in Python?</a>" but I'm confused. </p>
  
  <p>For example, when to do the conversion using:</p>
  
  <pre><code>from skimage import color
  from skimage import io
  img_gray = color.rgb2gray(io.imread('image.png'))
  plt.imsave('image_gray.png', img_gray, format='png')
  </code></pre>
  
  <p>However when I load the new image and check its shape:</p>
  
  <pre><code>img_gr = cv2.imread('image_gray.png')
  print(img_gr.shape)
  (196,256,3)
  </code></pre>
  
  <p>I tried the other methods on that thread but the results are the same. My goal is to have images with a (196,256,1) shape, given how much less computationally intensive it will be for a Convolutional Neural Network.</p>
  
  <p>Any help would be appreciated.</p>