title: How to extract Text regions in images using Matlab?
body: <p>I am writing a <code>matlab</code> program that will detect text in a natural scene images. I am taking help of <a href="http://videolectures.net/cvpr2010_epshtein_dtns" rel="nofollow noreferrer">this video lecture and paper</a>. I understood first few steps and did edge detection (I am adding images below). Now I want to extract(separate out) only text from final image. How do I do that?</p>
  
  <p>My code:</p>
  
  <pre><code>i = imread('f:\new.jpg');
  i1 = rgb2gray(i);
  imshow(i1);
  
  i2 = edge(i1,'canny',0.3);
  imshow(i2);
  
  se = strel('square',2);
  i3 = imdilate(i2,se);
  imshow(i3);
  
  i4 = imfill(i3,'holes');
  imshow(i4);
  
  [Ilabel num] = bwlabel(i4);
  disp(num);
  Iprops = regionprops(Ilabel);
  Ibox = [Iprops.BoundingBox];
  Ibox = reshape(Ibox,[4 92]);
  imshow(i);
  
  hold on;
  for cnt = 1:92
      rectangle('position',Ibox(:,cnt),'edgecolor','r');
  end
  </code></pre>
  
  <p>Final image:
  <img src="https://i.stack.imgur.com/39Icn.jpg" alt="enter image description here"></p>