Image.showpixels#

Image.showpixels(fmt: str | None = None, ax: Any = None, cmap: str = None, grid: int | None = 2, badcolor: str | None = None, **kwargs: Any) Any[source]#

Display image with pixel values

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

  • grid (int | None, optional) – line width for the grid, defaults to 2. Set to None for no grid.

  • ax (axes, optional) – The axes on which to display the window, defaults to current axes

  • cmap (str, optional) – colormap for displaying pixel values, defaults to custom midnight colormap

  • kwargs – additional keyword arguments passed to text annotations

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.

Text parameters can be set using kwargs with defaults:

  • color: “white”

  • fontsize: 6

To improve visibility a black stroke is applied to the text, which can be configured using additional parameters in kwargs:

  • linewidth: 2, for the path effect stroke

  • foreground: “black”, for the path effect stroke

  • alpha: 0.7, for the path effect stroke

By default, a grid is drawn to show the pixel boundaries, this can be turned off by setting grid=None.

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

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

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

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

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

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

showwindow can be used to superimpose a colored window on the image, and to get the pixel values in that window. This can be used to demonstrate window operations, such as convolution and morphological operations.

Seealso:

print disp