title: Creating a binary image
body: <pre><code>clear all;
  clc;
  imag = imread('286502.png');
  image_binary = im2bw(imag,0.85);   %converte image to binary
  image_binary = not(image_binary);
  
  figure(1);clf
  imagesc(image_binary);colormap(gray)
  </code></pre>
  
  <p>I am using this code to genarate a binary image of an ellipse having its inside as white while outside as black.But , the problem i am facing is that whenever the foreground and background of my input ellipse is either light or dark then the binary image becomes all black or all white.</p>