machinevisiontoolbox.Image.showpixels

Image.showpixels(textcolors=['yellow', 'blue'], fmt=None, ax=None, windowsize=0, **kwargs)

Display image with pixel values

Parameters:
  • textcolors (list or str, optional) – text color, defaults to [‘yellow’, ‘blue’]

  • fmt (str, optional) – format string for displaying pixel values, defaults to None

  • ax (axes, optional) – Matplotlb axes to draw into, defaults to None

  • windowsize (int, optional) – half side length of superimposed moving window, defaults to 0

Returns:

a moving window

Return type:

Window instance

Display a monochrome image with the pixel values overlaid. This is suitable for small images, of order 10x10, used for pedagogical purposes. For example it can be used to animate the operation of sliding window operations like convolution or morphology.

textcolors can be:

  • a colorname string, in which case all pixel values are displayed in that color

  • “grey”, in which case the pixel values are displayed in grey that is signficantly different from the pixel value

  • a 2-element tuple or list. The first color in textcolors is used for pixels below 50% intensity and the second color for those above 50%.

(Source code)

(Source code)

(Source code)

If windowsize is given then a translucent colored window is superimposed and a Window instance returned. This allows the window position, color and opacity to be changed.

Example:

>>> from machinevisiontoolbox import Image
>>> img = Image.Random(10)
>>> window = img.showpixels(windowsize=1) # with 3x3 window
>>> window.move(2,3) # position window at (2,3)
Image: 3 x 3 (uint8)
>>> window.move(4,5, color='blue', alpha=0.7)
Image: 3 x 3 (uint8)

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

../_images/machinevisiontoolbox-Image-showpixels-4.png

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

../_images/machinevisiontoolbox-Image-showpixels-5.png
Seealso:

print