title: How to extract and recognize the vehicle plate number with matlab?
body: <p>I want to develop a matlab program that can extract and recognize the plate number of vehicle with template matching method.
  Here is my code:</p>
  
  <pre><code>function letters = PengenalanPlatMobil(citra)
  %load NewTemplates
  %global NewTemplates
  citra=imresize(citra,[400 NaN]); % Resizing the image keeping aspect ratio same.
  citra_bw=rgb2gray(citra); % Converting the RGB (color) image to gray (intensity).
  citra_filt=medfilt2(citra_bw,[3 3]); % Median filtering to remove noise.
  se=strel('disk',1);
  citra_dilasi=imdilate(citra_filt,se); % Dilating the gray image with the structural element.
  citra_eroding=imerode(citra_filt,se); % Eroding the gray image with structural element.
  citra_edge_enhacement=imsubtract(citra_dilasi,citra_eroding); % Morphological Gradient for edges enhancement.
  imshow(citra_edge_enhacement);
  citra_edge_enhacement_double=mat2gray(double(citra_edge_enhacement)); % Converting the class to double.
  citra_double_konv=conv2(citra_edge_enhacement_double,[1 1;1 1]); % Convolution of the double image f
  citra_intens=imadjust(citra_double_konv,[0.5 0.7],[0 1],0.1); % Intensity scaling between the range 0 to 1.
  citra_logic=logical(citra_intens); % Conversion of the class from double to binary.
  % Eliminating the possible horizontal lines from the output image of regiongrow
  % that could be edges of license plate.
  citra_line_delete=imsubtract(citra_logic, (imerode(citra_logic,strel('line',50,0))));
  % Filling all the regions of the image.
  citra_fill=imfill(citra_line_delete,'holes');
  % Thinning the image to ensure character isolation.
  citra_thinning_eroding=imerode((bwmorph(citra_fill,'thin',1)),(strel('line',3,90)));
  
  %Selecting all the regions that are of pixel area more than 100.
  citra_final=bwareaopen(citra_thinning_eroding,125);
  [labelled jml] = bwlabel(citra_final);
  % Uncomment to make compitable with the previous versions of MATLAB®
  % Two properties 'BoundingBox' and binary 'Image' corresponding to these
  % Bounding boxes are acquired.
  Iprops=regionprops(labelled,'BoundingBox','Image');
  
  %%% OCR STEP
  [letter{1:jml}]=deal([]);
  [gambar{1:jml}]=deal([]);
  for ii=1:jml
      gambar= Iprops(ii).Image;
      letter{ii}=readLetter(gambar);
      % imshow(gambar);
      %
  end
  
  end
  </code></pre>
  
  <p>but the number recognized is always wrong and too much is detected or sometimes too little.
  How to fix it?</p>
  
  <p>Here is the <a href="http://i1360.photobucket.com/albums/r649/farhat1s/DSC_0512_zpsa99acbea.jpg" rel="nofollow">images</a> and <a href="http://i1360.photobucket.com/albums/r649/farhat1s/1_zpsaa2585c2.jpg" rel="nofollow">this one</a> </p>