title: Montage of grayscale and colour images
body: <p>Hi all I am using montage command of matlab to display images. However I am facing a problem. The command that I use is given below:</p>
  
  <pre><code>dirOutput = dir('C:\Users\DELL\Desktop\book chapter\Journal chan vese\robust 
  
  contour initialization\book for document\4 phase\*.jpg');
  fileNames = {dirOutput.name}'
  montage(fileNames, 'Size', [1 6]);
  export_fig combined1.jpg -r300
  </code></pre>
  
  <p>I have 6 images (all grayscale). However, the command prompt immediately <strong>throws an error like this:</strong></p>
  
  <pre><code>//Error using montage&gt;getImagesFromFiles (line 349)
  //FILENAMES must contain images that are the same size.
  
  //Error in montage&gt;parse_inputs (line 225)
  //    [I,cmap] = getImagesFromFiles(varargin{1});
  
  //Error in montage (line 112)
  //[I,cmap,mSize,indices,displayRange] = parse_inputs(varargin{:});
  
  //Error in montage_pics (line 3)
  //montage(fileNames, 'Size', [1 6]);
  </code></pre>
  
  <p>I am even uploading some of my images here:</p>
  
  <p><img src="https://i.stack.imgur.com/tidXJ.jpg" alt="1"><img src="https://i.stack.imgur.com/RtCx0.jpg" alt="2"><img src="https://i.stack.imgur.com/amN9s.jpg" alt="3"></p>
  
  <p>As can be seen clearly, <strong>all the images are grayscale</strong>. I then read the image size and they are as follows: </p>
  
  <p><strong>1.128X128 2.128X128*3 3.128X128*3 4.128X128 5.128X128*3 6.128X128*3.</strong> 
  So some of the images are treated as indeed colour images.</p>
  
  <p>My question is how to use the montage command for such images. Another problem is that montage command always needs images of similar sizes. So I wanted to avoid this loopholes.</p>
  
  <p>Of course I could use a software tool to convert the images to the required format but that is a bad way to work. I believe the below code if added to my original code will solve this problem</p>
  
  <pre><code>%Read Each Image
  I=imread('image');
  I=imresize(I,[128 128]);
  I=I(:,:,1);
  %Apply montage command
  </code></pre>
  
  <p><strong>However I have failed to integrate this code in my original code</strong>. Please help me to solve this problem. Thanks in advance guys for your valuable suggestions and help.</p>