TextureGenerator#
- class augraphy.utilities.texturegenerator.TextureGenerator(numba_jit=1)[source]#
Bases:
object
Core object to generate mask of texture in paper.
“normal” : Texture generated by multiple additions of normal distribution noise.
“strange” : Texture generated by an algorithm called “strange pattern”.
“rough_stains” : A rough stains similar texture generated by using FFT.
“fine_stains” : A fine stains similar texture generated by using FFT.
“severe_stains” : A severe stains similar texture generated by using FFT.
“light_stains” : A light stains texture covering the whole image. Generated using additive Median filter.
“random_pattern” : A random pattern texture generated by using FFT.
“dot_granular” : A granular texture generated using single directional gradient on dots of filled circle.
“light_granular” : A light granular texture generated using single directional gradient on gaussian noise.
“rough_granular” : A rough granular texture generated using using single directional gradient and stacking largest dots to smallest dots.
“curvy_edge” : Texture with distinct curvy effect on the images edges. Generated by using FFT.
“broken_edge” : Texture with broken images edges effect. Generated by using FFT.
- Parameters:
numba_jit (int, optional) – The flag to enable numba jit to speed up the processing.
- generate_FFT_grid(xsize, ysize, f_iterations, g_iterations, rresolutions, rA, rf, srp, srkx, srky, crp, crkx, crky)[source]#
Generate random wave grid, process it in FFT and convert it back into spatial domain.
- Parameters:
xsize (int) – The width of the output image.
ysize (int) – The height of the output image.
f_iterations (tuple) – Tuple of ints in determining the number of iterations in adding FFT converted wave grid.
g_iterations (tuple) – Tuple of ints in determining the number of iterations in summing grid waves.
rresolutions (tuple) – Tuple of floats in determing the resolution of grid image.
rA (tuple) – Tuple of ints in determining the amplitude of waves.
rf – Tuple of floats in determining the frequency of waves.
:type rf tuple :param srp: Tuple of floats in determining the phase of sine waves. :type srp tuple :param srkx: Tuple of floats in determining the x-component of sine wave vector. :type srkx tuple :param srky: Tuple of floats in determining the y-component of sine wave vector. :type srky tuple :param crp: Tuple of floats in determining the phase of cosine waves. :type crp tuple :param crkx: Tuple of floats in determining the x-component of cosine wave vector. :type crkx tuple :param crky: Tuple of floats in determining the y-component of cosine wave vector. :type crky tuple
- generate_broken_edge_texture(oxsize, oysize)[source]#
Generate a mask of broken edges based texture.
- Parameters:
oxsize (int) – The width of the output mask.
oysize (int) – The height of the output mask.
- generate_curvy_edge_texture(oxsize, oysize)[source]#
Generate a masked of curves based edge texture using FFT.
- Parameters:
oxsize (int) – The width of the output texture image.
oysize (int) – The height of the output texture image.
- generate_dot_granular_texture(oxsize, oysize)[source]#
Generate random granular texture using single directional gradient on dots of filled circle.
- Parameters:
oxsize (int) – The width of the output texture image.
oysize (int) – The height of the output texture image.
- generate_fine_stains_texture(oxsize, oysize)[source]#
Generate a fine stains similar texture using combination of normal distribution noise and FFT.
- Parameters:
oxsize (int) – The width of the output texture image.
oysize (int) – The height of the output texture image.
- generate_light_granular_texture(oxsize, oysize)[source]#
Generate light granular texture using single directional gradient on gaussian noise.
- Parameters:
oxsize (int) – The width of the output texture image.
oysize (int) – The height of the output texture image.
- generate_light_stains_texture(oxsize, oysize)[source]#
Generate light stains texture convering the whole image using additive Median filter.
- Parameters:
oxsize (int) – The width of the output texture image.
oysize (int) – The height of the output texture image.
- generate_normal_texture(xsize, ysize, channel, value=255, sigma=1, turbulence=2)[source]#
Generate random texture through multiple iterations of normal distribution noise addition.
- Parameters:
xsize (int) – The width of the generated noise.
ysize (int) – The height of the generated noise.
channel (int) – The number of channel in the generated noise.
value (int) – The initial value of the generated noise.
sigma (float) – The bounds of noise fluctuations.
turbulence (int) – The value to define how quickly big patterns will be replaced with the small ones.
- generate_random_pattern_texture(oxsize, oysize)[source]#
Generate random pattern texture using FFT.
- Parameters:
oxsize (int) – The width of the output texture image.
oysize (int) – The height of the output texture image.
- generate_rough_granular_texture(oxsize, oysize)[source]#
Generate rough granular texture using single directional gradient and stacking largest dots to smallest dots.
- Parameters:
oxsize (int) – The width of the output texture image.
oysize (int) – The height of the output texture image.
- generate_rough_stains_texture(oxsize, oysize)[source]#
Generate a rough stains similar texture using FFT.
- Parameters:
oxsize (int) – The width of the output texture image.
oysize (int) – The height of the output texture image.
- generate_severe_stains_texture(oxsize, oysize)[source]#
Generate severe stains texture using combination of fine and rough stains texture.
- Parameters:
oxsize (int) – The width of the output texture image.
oysize (int) – The height of the output texture image.
- static generate_strange_texture(oxsize, oysize)[source]#
Generate a random strange texture.
- Parameters:
oxsize (int) – The width of the output texture image.
oysize (int) – The height of the output texture image.
- generate_wave_grid(xgrid, ygrid, xsize, ysize, iterations, rA, rf, srp, srkx, srky, crp, crkx, crky)[source]#
Create grid of waves using heights of sine and cosine waves.
- Parameters:
xgrid (numpy array) – The x coordinates grid.
ygrid (numpy array) – The y coordinates grid.
xsize (int) – The width of the output grid image.
ysize (int) – The height of the output grid image.
iterations (tuple) – The number of iterations in summing waves.
rA (tuple) – Tuple of ints in determining the amplitude of waves.
rf – Tuple of floats in determining the frequency of waves.
:type rf tuple :param srp: Tuple of floats in determining the phase of sine waves. :type srp tuple :param srkx: Tuple of floats in determining the x-component of sine wave vector. :type srkx tuple :param srky: Tuple of floats in determining the y-component of sine wave vector. :type srky tuple :param crp: Tuple of floats in determining the phase of cosine waves. :type crp tuple :param crkx: Tuple of floats in determining the x-component of cosine wave vector. :type crkx tuple :param crky: Tuple of floats in determining the y-component of cosine wave vector. :type crky tuple
- get_random_patch(image_texture, image_hsv, patch_size, ysize, xsize, h_range, s_range, v_range)[source]#
Get patch of image from texture based on input hue, saturation and value range.
- Parameters:
image_texture (numpy array) – The input image texture.
image_hsv (numpy array) – The input image texture in HSV channel.
patch_size (int) – The size of each image patch.
y_size (int) – The height of image texture.
x_size (int) – The width of image texture.
h_range (tuple) – The range of reference hue values.
s_range (tuple) – The range of reference saturation values.
v_range (tuple) – The range of reference value values.
- quilt_texture(image_texture, patch_size, patch_number_width, patch_number_height)[source]#
Generate new texture image by quilting patches of input image.
- Parameters:
image_texture (numpy array) – The input image texture.
patch_size (int) – The size of each image patch.
patch_number_width (int) – The number of image patch in horizontal direction.
patch_number_height (int) – The number of image patch in vertical direction.
- remove_frequency(wave_grid_output, frequency1, frequency2=None)[source]#
Remove image area bigger than the input frequency by using FFT.
- Parameters:
wave_grid_output (numpy array) – The input image.
frequency1 (int) – The left end of frequency threshold.
frequency2 (int, optional) – The right end of frequency threshold.
Overview#
TextureGenerator is the core object to generate mask of texture in paper.