Image.Ramp#

classmethod Image.Ramp(cycles: int = 2, dir: str = 'x', *, size: int | Sequence[int] | None = None, dtype: Dtype | None = None, colororder: str | None = None, like=None) Self[source]#

Create image of linear ramps

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

  • size (int or 2-tuple, optional) – image size, width x height, defaults to 256x256

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

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

The short-name aliases 'int', 'float', 'double', 'half' are also accepted and resolve to the Toolbox’s own defaults (uint8, float32, float64, float16 respectively) – this matters because NumPy’s own np.dtype('float') resolves to float64, not float32. See DTYPE_ALIASES. :param colororder: color plane names for the output image, defaults to None :type colororder: str or None, optional :param like: template image supplying default size, dtype and

colororder when those are not given explicitly

Returns:

intensity ramps

Return type:

Image

The direction 'xy' creates a diagonal ramp.

The ramps 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.Ramp(cycles=2, size=10).print()
   0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00
   0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00
   0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00
   0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00
   0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00
   0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00
   0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00
   0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00
   0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00
   0.00 0.25 0.50 0.75 1.00 0.00 0.25 0.50 0.75 1.00
>>> Image.Ramp(cycles=3, size=10, dtype='uint8').print()
     0 109 218  71  72 182  35  36 145 254
     0 109 218  71  72 182  35  36 145 254
     0 109 218  71  72 182  35  36 145 254
     0 109 218  71  72 182  35  36 145 254
     0 109 218  71  72 182  35  36 145 254
     0 109 218  71  72 182  35  36 145 254
     0 109 218  71  72 182  35  36 145 254
     0 109 218  71  72 182  35  36 145 254
     0 109 218  71  72 182  35  36 145 254
     0 109 218  71  72 182  35  36 145 254

Ramps in the x, y and diagonal directions:

(Source code, png, hires.png, pdf)

../_images/machinevisiontoolbox-Image-Ramp-1.png