Reputation: 222
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?
Upvotes: 2
Views: 378
Reputation: 2201
mask_val = 2
rotated = skimage.transform.rotate(img, 15, resize=True, cval=mask_val,
preserve_range=False)
mask = rotated == mask_val
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. rotate
above transforms image pixels to normalized floats internally thanks to preserve_range=False
(this is default value, I specified it just to make point that without it this wouldn't work).
Upvotes: 1