title: Numpy resize and fill with specific value
body: <p>How can i resize a numpy array and fill it with a specific value (if some dimension is extended) ?</p>
  
  <p>I find a way to extend my array with <strong>np.pad</strong> but I can't shorten it:</p>
  
  <pre class="lang-py prettyprint-override"><code>&gt;&gt;&gt; import numpy as np
  &gt;&gt;&gt; a = np.ndarray((5, 5), dtype=np.uint16)
  &gt;&gt;&gt; a
  array([[0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0],
         [0, 0, 0, 0, 0]], dtype=uint16)
  &gt;&gt;&gt; np.pad(a, ((0, 1), (0,3)), mode='constant', constant_values=9)
  array([[0, 0, 0, 0, 0, 9, 9, 9],
         [0, 0, 0, 0, 0, 9, 9, 9],
         [0, 0, 0, 0, 0, 9, 9, 9],
         [0, 0, 0, 0, 0, 9, 9, 9],
         [0, 0, 0, 0, 0, 9, 9, 9],
         [9, 9, 9, 9, 9, 9, 9, 9]], dtype=uint16)
  </code></pre>
  
  <p>And if i use <strong>resize</strong> i can't specify the value that I want to use.</p>
  
  <pre><code>&gt;&gt;&gt; a.fill(5)
  &gt;&gt;&gt; a.resize((2, 7))
  &gt;&gt;&gt; a
  array([[5, 5, 5, 5, 5, 5, 5],
         [5, 5, 5, 5, 5, 5, 5]], dtype=uint16)
  </code></pre>
  
  <p>But i would like </p>
  
  <pre><code>&gt;&gt;&gt; a
  array([[5, 5, 5, 5, 5, 9, 9],
         [5, 5, 5, 5, 5, 9, 9]], dtype=uint16)
  </code></pre>
  
  <p>After some test I create this function but it's only work when you change x_value or with a lower y_value, if you need to increase y dimension it doesn't work, why ? </p>
  
  <pre class="lang-py prettyprint-override"><code>VALUE_TO_FILL = 9
  def resize(self, x_value, y_value):
      x_diff = self.np_array.shape[0] - x_value
      y_diff = self.np_array.shape[1] - y_value
      self.np_array.resize((x_value, y_value), refcheck=False)
      if x_diff &lt; 0:
          self.np_array[x_diff:, :] = VALUE_TO_FILL
      if y_diff &lt; 0:
          self.np_array[:, y_diff:] = VALUE_TO_FILL
  </code></pre>