Cython modules¶
- optimiser.fast_mask_denoise()¶
Fast in-place denoiser, focussed on speed rather than quality.
This function removes noise based on the amount of pixels in its neighbourhood
Args:
mask (numpy.ndarray[numpy.uint8, ndim=2]): mask, modified in place
width (int): width of mask
height int): height of mask
mincnt (int): min pixels in neighbourhood to not be counted as noise
n_size (int): neighbourhood size in all x and y (-n_size, +n_size)
Returns the input mask, denoised.
- optimiser.optimise_gray()¶
“Optimises” an input image for JPEG2000 compression, it does this by radiating pixels in the mask to pixels not in the mask, downwards and to the right. This (hopefully) allows for more optimal lossy compression of the pixels in the mask.
Grayscale version.
Args:
mask (numpy.ndarray[numpy.uint8, ndim=2]): input mask
img: (numpy.ndarray[numpy.uint8, ndim=2): input image
width (int): mask/img width
height (int): mask/img height
n_size: window size
Returns a new image (numpy.ndarray[numpy.uint8, ndim=2])
- optimiser.optimise_gray2()¶
“Optimises” an input image for JPEG2000 compression, it does this by radiating pixels in the mask to pixels not in the mask, downwards and to the right. This (hopefully) allows for more optimal lossy compression of the pixels in the mask.
Fast and grayscale version.
Args:
mask (numpy.ndarray[numpy.uint8, ndim=2]): input mask
img: (numpy.ndarray[numpy.uint8, ndim=2): input image
width (int): mask/img width
height (int): mask/img height
n_size: window size
Returns a new image (numpy.ndarray[numpy.uint8, ndim=2])
- optimiser.optimise_rgb()¶
“Optimises” an input image for JPEG2000 compression, it does this by radiating pixels in the mask to pixels not in the mask, downwards and to the right. This (hopefully) allows for more optimal lossy compression of the pixels in the mask.
RGB version.
Args:
mask (numpy.ndarray[numpy.uint8, ndim=2]): input mask
img: (numpy.ndarray[numpy.uint8, ndim=3): input image
width (int): mask/img width
height (int): mask/img height
n_size: window size
Returns a new image (numpy.ndarray[numpy.uint8, ndim=3])
- optimiser.optimise_rgb2()¶
“Optimises” an input image for JPEG2000 compression, it does this by radiating pixels in the mask to pixels not in the mask, downwards and to the right. This (hopefully) allows for more optimal lossy compression of the pixels in the mask.
Fast and RGB version
Args:
mask (numpy.ndarray[numpy.uint8, ndim=2]): input mask
img: (numpy.ndarray[numpy.uint8, ndim=3): input image
width (int): mask/img width
height (int): mask/img height
n_size: window size
Returns a new image (numpy.ndarray[numpy.uint8, ndim=3])
- sauvola.binarise_sauvola()¶
Perform fast Sauvola binarisation on the given input array/image.
Args:
in_arr (numpy.ndarray[numpy.uint8, ndim=1]): input array, flattened
our_arr (numpy.ndarray[numpy.uint8, ndim=1]): output array, flattened, must be allocated already
width (int): width of mask
height int): height of mask
window_width (int): Sauvola window width
window_height(int): Sauvola window height
k (double): k parameter
R (double): R parameter
Example usage:
>>> h, w = img.shape >>> out_img = np.ndarray(img.shape, dtype=np.bool) >>> out_img = np.reshape(out_img, w*h) >>> in_img = np.reshape(img, w*h) >>> binarise_sauvola(in_img, out_img, w, h, window_size, window_size, k, R) >>> out_img = np.reshape(out_img, (h, w)) >>> out_img = np.invert(out_img)