avi9526
avi9526

Reputation: 222

How to create mask for outer pixels when using skimage.transform.rotate

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? How to create such mask

Upvotes: 2

Views: 378

Answers (1)

featuredpeow
featuredpeow

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

Related Questions