title: How to get a pixel matrix from grayscale image in R?
body: <p>When grayscale images are represented by matrices each element of the matrix determines the intensity of the corresponding pixel. For convenience, most of the current digital files use integer numbers between 0 (to indicate black, the color of minimal intensity) and 255 (to indicate white, maximum intensity), giving a total of 256 = 2^8 different levels of gray.</p>
  
  <p>Is there a way to get a pixel matrix of graysale images in R whose pixel values will range from 0 to 255?</p>
  
  <p>It will also be helpful to know if I can resize the images in preferred dimension (say, $28 \times 28$) in R and then convert them into a pixel matrix whose elements range from 0 to 255? </p>
  
  <p>What happens if the original image is RGB but I want the matrix for grayscale?</p>