Demonstrations of the Bash-kernel Jupyter notebook capabilities

Linux commands and exercises are designed to be executed from a Linux terminal. However, there are several different ways that most of this functionality can be achieved from the Jupyter notebooks with the attendent advantage of built-in documentation capabilities.

  1. use the bash kernel to directly execute Linux commands.
  2. use IPython kernel %magic extensions such as ! to execute shell commands
  3. use the VisionX-V4 shell command XXXX
  4. use the python subrocess package library directly

The most direct method is to use the bash kernel which is considered here. Experienced IPython notebook users may enjoy the %magic extensions for Linux commands. The advantage of the VisionX-V4 shell command is that it provides a more convenient command syntax when using VisionX images in python programs.

The following outlines how to execute Linux commands in the Jupyter notebook bash kernel.

  1. traditional Linux commands

Linux command that return text results may be directly specified in code sections:

In [1]:
ls -sl nb-x4*
8 -rw-r--r--  1 reeves  staff  168 Feb  7 12:23 nb-x4.png
  1. Notebook image display

There is a mechanism to display simple images in png or jpeg format. For example, to display the histogram of a v4 image file:

In [2]:
vplot nyg2.vx -h -rpng of=hist2.png
display < hist2.png

Note the display command is really a bash function and there is no explicit image size scaling method. Therefore, to make large images fit into the page it may be necessary to pre-scale to the desired display size. However, it is possible to pipe into the display command. For example:

In [3]:
vqfile -q nyg2.vx
vimag nyg2.vx m=0.3,0.3,1 of=tmp1
vxport tmp1 -png of= |display
Format:     VXB
Size:       512 x 512
Pixel Type: byte
In [4]:
vclip if=nyg2.vx s=128 p=46,160 | vibbox -z of=nyg3.vx
vxtopnm nyg3.vx | pamtopng |display

  1. Interactive image display

Frequently when using visionx it is convenient to have vview running concurrently so that images may be viewed and annotated interactively. A process may be called from a notebook but may not be successfully put in the background For example the command

vview &

will create a usable vview from the notebook vview but further execution in the notebook will be prevented until the user exits from that vview.

Therefore, it is recommended that when using the vview and vdview image viewing tools, first start vview in the background before starting the jupyter notebook. If you have already started the notebook then you can open a new terminal and start vview from there.

  1. Detailed image display

Individual pixel values for a small image region may be conveniently displayed with the vinsp command.

In [1]:
vinsp if=nyg3.vx p=36,56 s=12,8 -p  | display

The vinsp command may also be used to show where the selected image region is located in the full image

In [7]:
vinsp if=nyg3.vx p=36,56 s=12,8 -p -r | display

The vinsp command may also be used with color images in which case teh three color values (R,G,B) are shown in each pixel

In [8]:
vclip if=nyc2.vx s=128 p=46,160 | vibbox -z of=nyc3.vx
vxport nyc3.vx -png of= | display

In [9]:
vinsp if=nyc3.vx p=36,56 s=12,8 -p  | display

In [10]:
vinsp if=nyc3.vx p=36,56 s=12,8 -p -r | display

In some cases it will be necessary in reports to include images that are created in the interactive image viewing tools (like v3d and vdview). For these cases, it is necessary to make a screen snapshot of the region, covert that image to jpeg or png if necessary and to import that image into notbook by using the display function.