Tutorial VisionX v4 and Python

Some samples are given below of using the v4 package to read write and display images.

  1. Examples are given of reading and writing v4 and other files with python
  2. Examples are given of displaying images with the v4 utilities
The following requires that the python visionx module be installed (pip install v4) and that a full version of VisionX v4 is installed. Testing was done on python3.6.

VisionX V4 images

The class vx.Vx is used to manage v4 images. There first example shows how such an image may be created within Python. The image is stored in a numpy array accessed by .i

VisionX images may be read for image files as in:

img = vx.Vx('file.vx')

For images in formats that are other than v4, the imageio package is useful. See below an example of reading a .png image, creating a python v4 structure from it and writing the image in VisionX format.

Visionx is able to directly read and write some standard image formats such as .png and .jpeg. For example:

Results from external command executions may be returned to python using the vxsh utility

Images may also be returned from external commands using the vxsh utility

Displaying Images in Jupyter Notebooks

One of the most direct ways od displaying v4 and other images in a python environment is to use the PIL package. The v4 vd utility dispvx may be use as shown below: Note, the image is displayed in native resolution which is often useful. However, scaling to fit may be necessary for large images

Another approach is to use the matplotlib package. In this case the image is always scaled and you have some control on the scaling; however you cannot show it in its actual native size. The v4 vd utility dispmvx may be used as shown below. Since this disply mode always invovles image scaleiing the actual image size is reported.


For small test images the vd utility dispsvx may be used whcih provides pixel values