title: Add black border to image in matlab
body: <p>I have some picture  A 
  and a size  <code>MaxH*MaxW</code> (as example 800*600)
  the picture size is smaller,
  i want to add black borders that in after the code the picture size will be 800*600</p>
  
  <p>i tried something like that :</p>
  
  <pre><code>function [ output_args ] = t( A)
  im=imread(A);
  global MaxH;
  global MaxW;
  global Max;
  
  [rowsA colsA numberOfColorChannelsA] = size(im); 
  % Get size of existing image B. 
  % See if lateral sizes match. 
  if MaxH ~= rowsA || MaxW ~= colsB 
  % Size of B does not match A, so resize B to match A's size. 
  % imresize(A, [MaxH MaxW Max]); 
  d=padarray(A,[(MaxW-size(im,1))/2 (MaxH-size(im,2))/2]);
  imwrite(d,A);
  end
  
  
  end
  </code></pre>
  
  <hr>
  
  <pre><code>                   **edit**
  
  function [ output_args ] = Resize( A )
  %TT Summary of this function goes here
  %   Detailed explanation goes here
  im=imread(A);
  global MaxH;
  global MaxW;
  global Max;
  
  [H W N] = size(im);
  
      y=floor((MaxH-H)/2);
      x=floor((MaxW-W)/2);
  
      d=padarray(im,[y x]);
  
  d= imresize(d,[MaxH MaxW]);
  imwrite(d,A);
  
  
  end
  </code></pre>
  
  <p>tnx to all</p>