title: Convert RGB-image to one-channel gray image in R EBImage
body: <p>An R-beginner question:</p>
  
  <p>I wanted to convert an RGB-Image to grayscale and display/plot it with image()</p>
  
  <pre><code>library(EBImage)
  orig = readImage("c:/test/b/s2.png")
  gray = orig
  colorMode(gray) = Grayscale
  
  display(gray) #works
  image(gray) #Error 'z' should be a matrix
  </code></pre>
  
  <p>The image converted by colorMode(gray) = Grayscale seems to be incompatible with image-function. Does Crayscale image in R EBImage has more than one channel?</p>
  
  <p>Then I converted it manually and was able to call image() on it</p>
  
  <pre><code>r = channel(orig,"r")
  g = channel(orig,"g")
  b = channel(orig,"b")
  
  gray1 = 0.21*r+0.71*g+0.07*b
  
  display(gray1) 
  image(gray1) #works
  </code></pre>
  
  <p>However, the images both gray differed slightly concerning intensity.
  Is there a way to convert RGB to one channel gray in R EBImage?</p>
  
  <p><strong>EDIT</strong>
  For answering the question, why EBImage:</p>
  
  <p>The package provides some image-processing functions. E.g. I could display easily the intensity graph (img2) of a scanned test-stripe (img1) using further EBImage commands:</p>
  
  <pre><code>blotgraph = resize(gblur(gray1,3),200,1)
  plot(blotgraph, type="l")
  </code></pre>
  
  <p>I was not aware how to solve such kind of tasks without EBImage</p>
  
  <p><img src="https://i.stack.imgur.com/0AmSc.png" alt="img1">
  <img src="https://i.stack.imgur.com/LOYS4.png" alt="img2"></p>