title: How do I use graythresh on an indexed image in MATLAB?
body: <pre><code>I = imread('coins.png');
  level = graythresh(I);
  BW = im2bw(I,level);
  imshow(BW)
  </code></pre>
  
  <p>The above is an example from the MATLAB documentation using a grayscale image. How can I make it work with an indexed image like <a href="https://i.stack.imgur.com/OsccS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OsccS.png" alt="alt text"></a>
   in <a href="https://stackoverflow.com/questions/2586539/why-do-i-get-an-all-black-grayscale-image-when-i-load-this-png-in-matlab">this post</a>?</p>