title: Scikit-image: How can I ignore / mask zero values from ndarray for interpolating afterwards?
body: <p>As you can see my question above, I would like to mask / ignore the zero values from a ndarray, which I would like to interpolate afterwards. I hope you can help me with this, because I am trying since many days to solve this problem.</p>
  
  <p><strong>What do I want?</strong></p>
  
  <p>I have many ndarrays with different length sizes, which I would like to interpolate, let's say in this case, to make it smaller.</p>
  
  <p><strong>This is how one of these arrays looks like:</strong></p>
  
  <pre><code>[0.0, 0.0, 0.0, 0.0, 0.0, 144.0, 144.0, 145.0, 145.0, 144.0, 143.0, 143.0, 0.0, 0.0, 0.0]
  </code></pre>
  
  <p>As you can see, it is always one row (let's call it "array_row"), with many elements (for this example I just wrote an array example with 15 elements)</p>
  
  <p><strong>How do I interpolate?</strong></p>
  
  <p>I am using the scikit-image resize method, like this:</p>
  
  <pre><code>new_array = skimage.transform.resize(array_row, (1, 10))
  </code></pre>
  
  <p>The result of this interpolation looks something like this:</p>
  
  <pre><code>[0.0, 0.0, 71.49999999, 144.0, 144.60344827, 145.0, 144.70896278, 143.0, 71.49999999, 0.0, 0.0]
  </code></pre>
  
  <p>When using the interpolation, this result is ok like this. The value "71.49999999" is because of the zero value before and / or after the non-zero values, which is normal.</p>
  
  <p>But for my case, I do not want that this happens. I would like to let <code>skimage.transform.resize</code> to ignore the zero values, so that the result would be something like this:</p>
  
  <pre><code>[0.0, 0.0, 144.0, 144.0, 144.60344827, 145.0, 144.70896278, 143.0, 143.0, 0.0, 0.0]
  </code></pre>
  
  <p>The values should not be changed (or at least only from the non-zero value next to it).</p>
  
  <p>I actually have no idea on how to do that. I tried something like masking and giving the masked  indices the value "255", which also does not give the result as expected.</p>
  
  <p>Do you have any idea on how to achieve this goal? </p>