machinevisiontoolbox.Image.Sin

classmethod Image.Sin(size=256, cycles=2, dir='x', dtype='float32')

Create image of sinusoidal intensity pattern

Parameters:
  • dir (str, optional) – sinusoid direction: ‘x’ [default] or ‘y’

  • size (int, optional) – image width and height, defaults to 256

  • cycles (int, optional) – Number of complete cycles, defaults to 2

  • dtype (str, optional) – NumPy datatype, defaults to ‘float32’

Returns:

sinusoidal pattern

Return type:

Image

The sinusoids are offset to have a minimum value of zero, and span the range:

  • float image: 0 to 1

  • int image: 0 to maximum positive value of the integer type

Example:

>>> from machinevisiontoolbox import Image
>>> Image.Sin(10, 2).image
array([[0.5   , 0.9755, 0.7939, 0.2061, 0.0245, 0.5   , 0.9755, 0.7939,
        0.2061, 0.0245],
       [0.5   , 0.9755, 0.7939, 0.2061, 0.0245, 0.5   , 0.9755, 0.7939,
        0.2061, 0.0245],
       [0.5   , 0.9755, 0.7939, 0.2061, 0.0245, 0.5   , 0.9755, 0.7939,
        0.2061, 0.0245],
       [0.5   , 0.9755, 0.7939, 0.2061, 0.0245, 0.5   , 0.9755, 0.7939,
        0.2061, 0.0245],
       [0.5   , 0.9755, 0.7939, 0.2061, 0.0245, 0.5   , 0.9755, 0.7939,
        0.2061, 0.0245],
       [0.5   , 0.9755, 0.7939, 0.2061, 0.0245, 0.5   , 0.9755, 0.7939,
        0.2061, 0.0245],
       [0.5   , 0.9755, 0.7939, 0.2061, 0.0245, 0.5   , 0.9755, 0.7939,
        0.2061, 0.0245],
       [0.5   , 0.9755, 0.7939, 0.2061, 0.0245, 0.5   , 0.9755, 0.7939,
        0.2061, 0.0245],
       [0.5   , 0.9755, 0.7939, 0.2061, 0.0245, 0.5   , 0.9755, 0.7939,
        0.2061, 0.0245],
       [0.5   , 0.9755, 0.7939, 0.2061, 0.0245, 0.5   , 0.9755, 0.7939,
        0.2061, 0.0245]], dtype=float32)
>>> Image.Sin(10, 2, dtype='uint8').image
array([[127, 248, 202,  52,   6, 127, 248, 202,  52,   6],
       [127, 248, 202,  52,   6, 127, 248, 202,  52,   6],
       [127, 248, 202,  52,   6, 127, 248, 202,  52,   6],
       [127, 248, 202,  52,   6, 127, 248, 202,  52,   6],
       [127, 248, 202,  52,   6, 127, 248, 202,  52,   6],
       [127, 248, 202,  52,   6, 127, 248, 202,  52,   6],
       [127, 248, 202,  52,   6, 127, 248, 202,  52,   6],
       [127, 248, 202,  52,   6, 127, 248, 202,  52,   6],
       [127, 248, 202,  52,   6, 127, 248, 202,  52,   6],
       [127, 248, 202,  52,   6, 127, 248, 202,  52,   6]], dtype=uint8)