title: How to convert an indexed image to rgb image in MATLAB?
body: <p>I did a gaussian filter and the image become index. I have to use <code>imagesc</code> to show the determine the color difference. How can I convert it to rgb so that I can do further process.</p>
  
  <p><strong>Edited</strong> Added some images, top is the 'original image', 'imshow(C)', 'imagesc(C)' respectively. Then I just want the 'C' variable to be like imagesc image. Is it possible??</p>
  
  <p><img src="https://i.stack.imgur.com/d5NZK.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/UI9SS.png" alt="enter image description here">
  <img src="https://i.stack.imgur.com/MKpla.png" alt="enter image description here"></p>
  
  <p><strong>Edited</strong> Here is my coding, see from gaussian onward</p>
  
  <pre><code>% Read Image
  rgb = imread('barcode.jpg');
  % Resize Image
  rgb = imresize(rgb,0.33);
  %figure(),imshow(rgb);
  % Convert from RGB to Gray
  Igray = rgb2gray(rgb);
  BW2 = edge(Igray,'canny');
  %figure(),imshow(BW2);
  % Perform the Hough transform
  [H, theta, rho] = hough(BW2);
   % Find the peak pt in the Hough transform
  peak = houghpeaks(H);
   % Find the angle of the bars
  barAngle = theta(peak(2));
  J = imrotate(rgb,barAngle,'bilinear','crop');
  %figure(),imshow(J);
  Jgray = double(rgb2gray(J));
  % Calculate the Gradients
  [dIx, dIy] = gradient(Jgray);
  %if min(dIx(:))&lt;= -100 &amp;&amp; max(dIx(:))&gt;=100 || min(dIy(:))&lt;=-100 &amp;&amp; max(dIy(:))&gt;=100
  if barAngle &lt;= 65 &amp;&amp; barAngle &gt;=-65 &amp;&amp; min(dIx(:))&lt;= -100
      B =  abs(dIx) - abs(dIy);
  else
      B = abs(dIy) - abs(dIx);
  end
  % Low-Pass Filtering
  H = fspecial('gaussian', 20, 10);
  C = imfilter(B, H);
  C = imclearborder(C);
  figure(),imshow(C);
  figure(),imagesc(C);colorbar;
  </code></pre>