Image Shift Measurement
Given a series of similar images that are slightly shifted relative
to each other, this example shows how to crop out a region of interest from
all of them, and measure the relative shifts using the Data Cube Tool,
FFT Tool, Process Folder Tool, and Blob Tool.
The images are EBSD images, in a folder called tracking-sample,
and were taken by Mark Vaudin of NIST. The folder of images is available
from the NIST Lispix website: http://www.nist.gov/lispix/images/.
To view the images and their shifts, load them into the Data Cube
Tool, and show them as a movie:
- TOOLS / Data Cube Opens the Data Cube Tool.
The TOOLS menu is 6th from the right in the menu bar:

- R! button (left most blue convenience button
just under the Lispix menus. Navigate to, and select one of the sample
images. Which one is not important. All that this does is set
the Lispix read directory to the folder containing the image that you clicked.
- read / as image files. The read
menu is in the upper left green button. Read
/ as image files opens a cube window with each of the images
as a slice of the cube. To select a contiguous range of files, click
on the top one, then holding down the shift key, click on the bottom one.
To select discontiguous files, hold down the control key and click on each
one.

The cube, as loaded will look like this. The slice slider is below the
cube - move the slider to see different slices.
- Or, Use movie! to run through all of them.
-
- First select the cube by clicking the cube! button.
(Orange, just below the 'movies and registration' line, and on the left.)
- Then click on movie! (Green, left of center in the
lower half of the data cube tool.)
- Click on off! to stop the movie. It is not a
good idea to keep the movie running, and do other things with your computer.
- The first time through, Lispix is making pixmaps for display, and will
take a few seconds for each image.

In order to measure the relative shifts from one slice to the next, we will
convolve all of the images by the first one. The bright spot in the cross-correlation
gives the shift of the one image relative to the other. We wish to measure
the positions of the bright spot in image 1 correlated with itself, then correlated
with image 2, etc. To convolve, first select a square area of interest,
with edge length in pixels of a power of 2.
- Select / select square with click / 256 / click on the bright center of
the image.
- Select the size using the dialog. 'other' is available for squares
with edges that are not powers of two. This is not recommended for
the convolution operation to follow, as the padding which results will
obscure the bright spot mentioned above.

- Once the size is selected, Lispix will show the region of the image
within which you may select the center of the square region:

- Clicking on the center of this EBSD pattern results in the square selection,
which you will then use to crop the cube.

- Once this region is selected as above, use the cube button
in the data cube tool (Green, right of center in the upper part of the tool),
which is for making new data cubes out of the front data cube. Use
cube / crop using rectangle.

Alternatively, if you have not loaded into the data cube all of the images
that you wish to crop, you can use the Process Folder Tool.
This ignores the above cube. Briefly,
- Set the read directory to the original images.
- Set the write directory to a new folder for the cropped images.
- Use Process Folder / Text file / Template to make the boiler
plate processing file. The sample crop command has the dimensions that
you set in the previous steps.
- Use Text file / Save & assign. This stores the
text file in the write directory where the cropped images will go.
- Use Process Folder! This will crop all of the images.
- If you wish to see the cube containing the cropped images, set the read
directory to the cropped folder, then use the data cube Tool: read
/ as image files.
The resulting cube looks like this: It will appear on top of the original
cube, which you can now close by clicking on its "X" button.

This smaller cube consists of seven images, which must be saved so that they
can be convolved with the first image, using the process folder Tool.
- Make a folder for the new images, and set the Lispix write directory to
this folder.
- For illustrative purposes, I made a temp folder on
my desktop, which is no where near the input folder.
- Set the write directory to this folder. To do this, expand
the Lispix Menu Bar.
- Use W / set to sample file. The W
button is blue, on the left, third from the top.
- Navigate to the temp folder.
- In this case, there was no sample file to select, because the folder
was new. Make one within the selection dialog by right-clicking
where files should appear, choose New / Text Document,
or whatever you like, make and select it. This file will not
be used for anything else, and was not opened by Lispix. It's
only purpose was to enable the use of the dialog to select it, which
is much preferable to the folder selection dialog.
- After the temp folder is selected, the W directory should be C:\Documents
and Settings\<user name>\ Desktop\temp\
- Save the new cube to this folder. data cube / write / original
slice names . The folder, viewed as thumbnails, looks like
this:

- You may now close the small data cube. You no longer need it.
You may also close the data cube Tool.
- To convolve these files with the Process
Folder Tool:
- Make a new folder for the files. I used temp2 on the desktop.
- The read directory should be temp, which was the write
directory for a previous operation. The temp directory (bottomline
in the expanded menu bar) should still be set to temp.
If it isn't, you can select the temp directory using the
<-! and ->! buttons. The temp directory
remembers all previous directories. Use R / set to temp.
- The write directory should be temp2. Use
W / set from ^ read / click on temp2, for
example.
- Open the image with which all of the images you select in the read folder
will be convolved. File / open / select the first
image.
- Open the Fourier Tool: Filter / Fourier Transform.
Click on image1: to select the image you just opened.
- Open the process folder Tool. TOOLS / process
folder.
- Make a sample text file with commands:
Text file: / Template.
- Add commands to the bottom of this file. Since the read and
write directories have been set, and the image opened and selected in
the FFT Tool, the template already has the appropriate commands
in the comment lines. Cut and paste 'convolve...', 'swap quads',
and 'scale...' to the bottom of the file:

- Then, use Text file: / Save & assign. This
will save the file as process-images.txt in the write directory (where the
processed images will go), and close the window you just edited.
- Use Process Folder! to convolve the images. The files
look like this:

- You may now close the image, the Fourier Tool, and the
Process Folder Tool.
The next steps use the Blob Tool to measure the positions
of the bright spot in the center of the convolved images. A threshold
must be chosen that selects the bright spot in all of the images. A convenient
way to do this is to read the images into the data cube tool, select a threshold
with a Threshold Slider, propagate that threshold through the cube for examination,
and then blob this folder of images.
- Read the images into a cube:
- Set the Read directory to temp2.
- Open the Data Cube Tool.
- data cube / read / as image files

- Open a Threshold Slider, and select intensities 200 - 255

- Propagate the threshold down to the other slices: Propagate
/ LUT.
- Show the cube as a movie, or inspect with the slice slider (now underneath
the Threshold slider, which you can now close if you wish).
When the thresholds all look OK, you can blob the images with the Blob
Tool. The temp2 cube can be closed, which will close both of
the sliders associated with it. You may also close the data cube Tool.l
- For simplicity, select the temp2 folder as the read, write and blob directories.
The read and write directories should already be set this way. To
set the blob directory, use B / set to temp.
- Open the Blob Tool: TOOLS / Blob. The minimum
area parameter of 10 pixels, and the touch edge parameter disallowed, are
satisfactory.
- Open the Process Folder Tool.
- Use: Files in Folder / Blob.
- Type in the thresholds that you see in the threshold slider.
In this case, 200 255
- This will put seven *.blob files in with the convolved images.
These blob files record the outlines of the blob(s) in each image.
Now that the convolved files have been blobbed, all that remains is to write
out the centroids to a file that can then be imported into Excel.
- First, select the statistics you want in the Blob Tool: Blob
Tool / Stats / Set stats / select ' Intensity -mean, -limits, -range,
'weighted centroid., because we desire the intensity weighted centroid as
the best measure of the position of the bright spot.
- In the Process Folder Tool, use: Files in folder / Blob
Stats to file
- This uses the images and blob files.
- Since the images are in both the read and write directories (which
are the same), just select the read directory.
- The file 13Dec05-stats.txt has the measurements
in columns. Use Excel to read them: in Excel - File
/ Open / select text files for the file type, then select the
file. The results look like this:
