title: MATLAB: Show colorbar of a grayscale image in a figure containing a RGB image
body: <p>Suppose we have two images:</p>
  
  <p>1) RGB Image:</p>
  
  <pre><code>% initialize RGB image:
  rgbIm = zeros(100, 100, 3); 
  rgbIm(20:80, 20:80, 1) = 1;
  </code></pre>
  
  <p>2) Grayscale Image:</p>
  
  <pre><code>% initialize grayscale image:
  grayIm = zeros(100);
  grayIm(20:80, 20:80) = 1;
  </code></pre>
  
  <p>Lets show both of them:</p>
  
  <pre><code>figure, imshow(rgbIm),  colormap('jet'), colorbar;
  figure, imshow(grayIm), colormap('jet'), colorbar;
  </code></pre>
  
  <p>As we can see, the <em>colorbar</em> in the 2nd figure (i.e. grayscale image) makes total sense. On the other hand I can't really understand the information given by the colormap in the 1st figure.</p>
  
  <p>What I would like to achieve is to <strong>display the colorbar of the grayscale image in the figure corresponding to the RGB image</strong>.</p>
  
  <p>It might seem that this does not make sense but this is just a very minimal example that I just made up to show what I would like to do in a larger project.</p>
  
  <p>Any thoughts?</p>
  
  <p>Thanks a lot :)</p>
  
  <p><strong>EDIT1:</strong> Allow me to explain why I would need this</p>
  
  <p>Suppose I compute some physiological parameters one MRI slice in certain regions of interest, yielding something like this:</p>
  
  <p><img src="https://i.stack.imgur.com/41tHW.png" alt="parametric image"></p>
  
  <p>Now I want to superimpose these parameters on top of the original slice, and I create one RGB image to achieve this:</p>
  
  <p><img src="https://i.stack.imgur.com/5o4Yo.png" alt="superimposition on the original image"></p>
  
  <p>The colormap does not make sense, and this is why I would like to display the colormap corresponding to the parametric image in the RGB image (i.e. the superimposition image).</p>
  
  <p>Any ideas?</p>
  
  <p>Thank you for your attention.</p>