How to create mask for outer pixels when using skimage.transform.rotate
<p>skimage rotate function create "outer" pixels, no matter how this pixels extrapolated (wrap, mirror, constant, etc) - they are fake, and can affect statistical analysis of image. How can I get mask of this pixels to ignore them in analysis?
<a href="http://i.stack.imgur.com/xzg5n.png" rel="nofollow"><img src="http://i.stack.imgur.com/xzg5n.png" alt="How to create such mask"></a></p>

<pre><code>mask_val = 2
rotated = skimage.transform.rotate(img, 15, resize=True, cval=mask_val, 
                                   preserve_range=False)
mask = rotated == mask_val
</code></pre>

<p>Idea: pick a value for the mask which doesn't appear in the image, then obtain mask by checking for equality with this value. Works well when image pixels are normalized floats. <code>rotate</code> above transforms image pixels to normalized floats internally thanks to <code>preserve_range=False</code> (this is default value, I specified it just to make point that without it this wouldn't work). </p>

python skimage